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.

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 * * 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.

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.