LED Nightlight

For this project I wanted to design a night light for use in the nursery with the following specifications:

– Diffused lighting source
– Multiple lighting modes – warm glow and bright modes
– Built in timer to turn off or dim after a set period of time
– Externally Powered from 5V supply
– Remote control functionality

A suitable embodiment for the nightlight as found on eBay and Amazon. This was a PIR light with a large diffuser which looked to be simple to disassemble and modify for my purposes:

PIR Decorative Light

PIR Decorative Light

The light was originally designed to be powered from 3x AAA cells and illuminated for around 30 seconds when movement was detected and initial testing revealed that the light provided adequate illumination of the room with the fitted diffuser. The light was disassembled to determine it’s suitability for fitting a custom PCB.

The schematic design for this nightlight is relatively trivial. Starting with the microcontroller, I selected a Microchip PIC24F32KA302, which had a suitable number of hardware PWM channels and some EEPROM built in for storing brightness settings.

Microcontroller - PIC24F32KA302

Microcontroller – PIC24F32KA302

A simple linear regulator provides power to the MCU from the 5V supply.

3.3V Linear Regulator

3.3V Linear Regulator

A white LED source was selected – a pair of Cree XLAMP MX-6 warm white LEDs were chosen to be the main light source for this nightlight and the driver was designed to provide a constant current of around 170mA to the LEDs at full duty cycle. The driver is expected to be connected to a PWM output from a microcontroller for brightness control.

White LED Driver

White LED Driver

A pair of red and amber LEDs are added to the design to allow a low level warm glow in the room when a main light source is not required. Kingbright KA-3529 LEDs are used for this purpose along with a similar LED driver.

Amber and Red LED Driver

Amber and Red LED Driver

I wanted the light to be simple to control remotely, so some infrared remote controllers were purchased from eBay.

Keyes IR Remote Kit

Keyes IR Remote Kit

These IR remotes use a 38kHz carrier frequency for modulation of the data stream. Following some initial investigations using the free IR receiver and an oscilloscope, I determined these remotes use the NEC protocol which has the following properies:

Modulation:
Carrier Frequency – 38kHz
Pulse Distance Modulation Protocol
– Logical 0 – 560µs 38kHz burst, 560µs break – 1.125ms total
– Logical 1 – 560µs 38kHz burst, 1.68ms break – 2.25ms total

38kHz NEC Carrier Details

38kHz NEC Carrier Details

Protocol:
Message starts with 9ms AGC burst followed by 4.5ms
Total bits transmitted = 32
Address and Command = 8 bits each
Address and Command are transmitted twice, the second transmission has all bits inverted for verification
Total transmission time always constant because every bit is transmitted with its inverted length.

NEC Protocol Details

NEC Protocol Details

To interface this with the microcontroller, a Vishay TSOP344 series IR receiver is used:

Vishay IR Receiver

Vishay IR Receiver

A few other expansion headers are provided on the PCB for future use, but the nightlight is designed to be controlled entirely from the IR remote control.