This is a little night-light that comes on when it gets dark, to illuminate dark rooms or hallways. Iām sure you can buy these cheaply ready made but itās more fun to make your own, and this way it can be customised exactly how you want it.
Power efficiency
The unit is very efficient ā I use 4x AA NiMH batteries which last over a month in typical use. The circuit uses a high-brightness LED, but driven at a lower current. The firmware makes use of the Picaxeās āSLEEPā command, so that the CPU is only running for a fraction of the total uptime.
I donāt want to put a dollar figure on the parts, because each user will have different sources for their parts (Iāll provide some links later). By fabricating my own circuit board I built the whole thing for under ten US dollars.
Step 1: Design
Itās a pretty simple circuit, based on an 8 pin Picaxe 08M. This was what I had on hand, you could also use the newer 08M2.It uses an LDR and a 1M2 resistor to form a voltage divider on pin 1 of the Picaxe. Thereās an orange LED connected to pin 4 of the Picaxe via a 1k2 resistor. This limits the current through the LED to about 5mA. This reduces the LED brightness, but itās still sufficient to provide a dim light if your eyes are adjusted to the darkness (I use it in my hallway so I can avoid tripping over at night, but not wake the household by turning on the main light)
Pulldown resistors are used on the unused Picaxe pins ā itās good practice not to allow I/O pins on a microcontroller to āfloatā and I think it also reduces current consumption very slightly. I used 110k resistors for the pulldowns, because I had a lot on hand. You could use anything around 100k.
The LED is driven straight from the Picaxe so itās important to limit the total current from this pin to under 20mA.
The cicruit draws less than 1mA when the LED is off, and about 5.5mA when the LED is on. I run mine from 4 AA NiMH rechargeable batteries (which supply about 5V) which last about a month on average, before I need to recharge them.
Software
The software spends most of its time in āsleepā mode, and only wakes up every 2.3s to check the state of the LDR. Before reading the LDR, it turns off the LED so that its light output doesnāt affect the reading. The reading happens so quickly the LED can hardly be seen to flicker when it is very briefly turned off. In order to avoid the LED turning on and off repeatedly around dusk, some hysteresis is built into the code. This is done very roughly by calculating an average value for the ambient light, so that changes in the ambient light take a while to propagate in the code. The raw ADC reading is also divided by 10 to minimise noise.
The code I have attached works on the Picaxe 08M. You should be able to convert it to run on the 08M2 by using the wizard built-in to the Picaxe software
LDR: Simliar to Philips ORP12. I used the RD3480 from www.jaycar.com.au
LED: high-brightness 5mm amber LED. I used the ZD0295 from www.jaycar.com.au
PCB: A custom board I designed in Eagle and etched myself. All the design files are attached to this Instructable
Case: I designed the above PCB to mount in a HB6005 clear plastic case from www.jaycar.com.au
Capacitors: 1x 100uF 16v; 1x 100nF, 50v.
Resistors: 1x 1M2; 2x 110k; 1x 22k; 1x 10k; 1x 1k2. all are 1/4w meetal film types (but it probably doesnāt matter)
Miscellaneous: Power socket, battery holder (the circuit requires 5V ā I used 4x 1.2V AA rechargeable batteries), programming header, about 15cm of insulated hookup wireIf thereās a lot of interest for this circuit, Iāll get a batch of PCBs and make a kit available.
Downloads