Picaxe LED night light

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.

Picaxe LED night light
Cost

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

Circuit
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

Picaxe LED night light
Hardware
CPU: Picaxe 08M.
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

Below are the Eagle files for the schematic and PCB. Thereā€™s also a full-size PDF of the PCB tracks if youā€™re etching your own PCB.
For more detail: Picaxe LED night light

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter