Simple automatic kitchen sink light

PROBLEM: Even when both ceiling lights are on in the kitchen, the sink has always been too dark at night. Anyone standing at the sink creates a shadow from the ceiling light, making it tough to properly wash dishes or vegetables.

SOLUTION: Install a light above the sink.

BONUS ROUND: Build the light from parts I already had, and make it automatically turn itself on and off.

I decided to build it using stuff from around the house. Of course, this isn't just any house...this is a geek house! So the components below were naturally considered household items. I decided to use an ATtiny84 as the heart of the project. It's way under-utilized here, but I didn't have any ATtiny25s in stock. I could have used a 555 instead of a microcontroller, but then I wouldn't have gotten a cool fade-in and fade-out PWM effect. Plus the 555 at one minute or higher time scales is a little ungainly, with the high value capacitor required. And I REALLY wanted a smooth fade-in. I would have also needed to invert the trigger signal from the PIR sensor.

Parts list:

  • PIR Motion Sensor
  • ATtiny84
  • 16 100mA white 10mm LEDs
  • LM340T-5.0 regulator
  • IRF612 MOSFET (not ideal, but works)
  • Old RadioShack proto board (do they even still sell those?)
  • 10uF capacitor
  • 0.1uF capacitor
  • 4 39ohm resistors
  • ~15V DC power supply
  • Wire and solder
  • Poster board
  • Zip ties

The schematic: Here's a quick schematic of the build. Very simple. The IRF612 is not really a logic level FET, but for the current we're using it's not a big problem. Threshold for Vgs is 2-4 volts, so 5V is okay. I'd have used a better FET if I had one around, but this doesn't even warm up as-is. Didn't bother with a series or pulldown resistor here.

kitchenlightschematic

Coding: This project was partly spurred by downloading Atmel's new AVR Studio 5. It's based on Visual Studio 2010, it's a bloated 500+ MB download, it's proprietary, it's Windows-only...but it is a really nice way to write code. Obviously the more complex programs will benefit from all the code exploration features in AVR Studio 5, but Intellisense is always welcome on even the smallest projects. AVR Studio 4 felt a lot closer to the hardware, but I'm sure that was infuriating for the developers using the larger processors.

The code simply watches the input from the PIR sensor, maintains a few counters and fades the PWM up and down accordingly. It is set to keep the light on as long as there is activity, or 60 seconds since the last activity. Accuracy is not really needed, so the internal 8MHz oscillator was selected using the AVR fuse configuration tool in AVR Studio.

KitchenLight.c

/*
 * KitchenLight.c
 *
 * Created: 3/4/2011 12:47:30 AM
 *  Author: Garrett
 */ 

#define F_CPU 8000000

#include <avr/io.h>
#include <util/delay.h>

int fadestate = 0;
int triggered = 0;
int ontimer = 0;

int main(void)
{
	DDRA = 0b00000000;
	DDRB = 0b00000100;
	PORTA = 0;
	TCCR0A = (1<<COM0A1)|(1<<WGM01)|(1<<WGM00);
	TCCR0B = (1<<CS00);
	TCNT0 = 0;
	OCR0A = 0;
	
    while(1)
    {
		
		if (PINA & (1<<PINA2)) {
			triggered = 1;
			ontimer = 6000;
		}
		
		if (ontimer > 0) {
			ontimer--;
		} else {
			triggered = 0;
		}
		
		if (triggered) {
			if (fadestate < 255) {
				fadestate++;
			}
		} else {
			if (fadestate > 0) {
				fadestate--;
			}
		}
		
		if (fadestate > 0) {
			TCCR0A |= (1<<COM0A1);
			OCR0A = fadestate;
		} else {
			TCCR0A &= ~(1<<COM0A1);
		}						

		_delay_ms(10);
										
    }
}

The build: Construction is embarrassingly simple, should be considered temporary until it falls apart. The main structural component is white foamcore poster board, with some packing tape and hot glue and a couple zip ties to keep things together. Holes were punched for the LEDs and the PIR sensor dome, then everything was hot glued in place.

Auto kitchen lightAuto kitchen lightAuto kitchen light

The installation: The resulting light bar was installed over the kitchen sink using some 3M Command hooks and a couple zip ties. Everything works as advertised! Approach the sink and the light will fade on. As long as motion events are captured in the PIR sensor range (washing dishes, etc) the light will stay on. If there is no activity for 60 seconds, it will fade off.

Auto kitchen light


Submitted by Garrett on Sat, 03/05/2011 - 23:23.

Very cool. Thanks for the

Very cool. Thanks for the schematic.

The ugly curtains distract

The ugly curtains distract from the wire. Was that intentional? ;-)

The curtains came with the

The curtains came with the house, and since there are only nerdy guys here no one notices stuff like that. I honestly forgot they were there until I saw them in the photo.

Oh, I see. Well, if you get

Oh, I see. Well, if you get your own nerdicile at some point, you should install an illuminated sink. Might pay for itself in prevented trips to the emergency room if one could see knives or broken glass in the water. Plus look cool.

Kidding aside, having a

Kidding aside, having a hands-free light over the kitchen sink is genius, of course. Great work!

Just curious but what

Just curious but what frequency are you using for your pwm?

Ryan, if you read back the

Ryan, if you read back the configuration from the TCCR0 registers and compare with datasheet, you would discover I am using "Fast PWM" (it's just standard non phase corrected PWM). It's an 8 bit timer with no clock prescaling, so I'm almost positive it's about 31KHz. Haven't actually measured it. In any case, it works well enough. It seems to be fast enough that no pulsing is visible on camera.

What was the total cost for

What was the total cost for all the equipment?

Garrett, thanks for the

Garrett, thanks for the details. I usually comment the timer registers in my code for the PICs that I
use. Since I don't work with Avrs too much I thought I'd ask. Great project. Im looking at doing something like this for my lab bench.

I've been working on a

I've been working on a project off and on with a couple of PIRs and a handfull of leds. good work.

also - AVR studio 5 is bloatware, but in all honestly, it only took me 20 min to get it downloaded and installed. not THAT big of a deal. It's a lot more aesthetically appealing than the last version IMO.

Visual studio has a great built in feature for version control support. you can find a free VC online and it will help you keep track of your projects better - if you screw up - just convert back to an older version.

Garrett, could I use the

Garrett,
could I use the P/N: ATtiny25-20SSU (Microcontrollers (MCU) 8-bit 5V 20MHz) from Mouser?
also, suggest a better MOSFET while I'm doing a BOM from Mouser?

Happy Garrett Day

Happy Garrett Day

source code is

source code is available?

thanks!
marC:)

Hi! Nice project! I cannot

Hi! Nice project! I cannot get it programmed using this command : avrdude -p t84 -c usbasp -U flash:w:kitchen-light.hex
can you help me out please?

thanks!
marC:)

Hi! When i powered it up the

Hi! When i powered it up the led are all on, when i get away from PIR shut off. When i show up on PIR, the led are not fading, and they are not showing lights

:(

thank you!
marC:)

I used a IRF624 MOSFET, it

I used a IRF624 MOSFET, it seems the led are on at first. Then i go away, the led turn off, i go back in front of the PIR sensor then, the led doesn't turn off at all. Is it the MOSFET the problem ?? i don't know this type of this transistor...

thank you!
marC:)