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 from Atmel 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.
PIR Sensor SEN116A2B
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.
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.
Source Code (AVR Studio 5) - download
News on theme: