Introduction: LED Night Lamp With Motion and Darkness Sensor

This is a battery powered DIY project. The device automatically switches itself on when motion is detected. It can be used in bedrooms, washrooms, closets or dark court etc. to have light if it is needed, no AC power is needed. The colour of the RGB LED can be set up with a help of the left potentiometer. There is a second potentiometer, which can modify the sensitivity for external light (sun, other lamps), with that it will turn the LED-s on only if it is really dark. The Arduino is in sleep mode, only the motion detector is powered on. In case of motion, the Arduino is powering on checking the photo resistor, if the measured AD value of the photo resistor is brighter than the level of the right potentiometer it turns on the LED as long as the motion sensor is active. Before the LED is turned on the Arduino checks the level of the left potentiometer, and change the colour according to this level. It starts with one colour (red, blue, green), than two colours (red-blue, blue-green, red-green) and three colours (red-blue-green). The sensitivity of the motion sensor and the activation time is changeable also on the motion module with dedicated potentiometer. It need 3 pcs of AAA batteries, because of the light sensor and power down mode it can operate for long time of period.

Step 1: Components and Tools

Find a box which has the right size for all the components. Collect together all the following components:

  1. 1pc. IR Infrared Motion Detection Sensor Module (DC 5V~20V)
  2. 1 pc. 5MM Photoresistor GL5537 LDR Photo Resistors Light-Dependent
  3. 2 pcs. Silver Tone Metal Split Shaft Potentiometer 50K Ohm
  4. 2 pcs. Black Knob Blue Face Rotary Switch Potentiometer Volume Pointer Hole 6mm
  5. 2 pcs. Keyes RGB LED Module for Arduino (Works with Official Arduino Boards)
  6. 1 pc.Pro Mini Microcontroller Circuit Board for Arduino (5V / 16MHz)
  7. 1 pc.1/4W Resistance Metal Film Resistors 2k2
  8. 2 pcs.AAA Batteries Holder Case Box
  9. 3 pcs.DURACELL AAA 1.5V Alkaline Batteries
  10. 1 pc.Mini Bread Board
  11. 25 pcs.Colored dupont Cables


  1. Drill
  2. Blade

Step 2: Connect the Components

Follow the schematic picture and connect all the components. Ifyou have a current limiter power supply use it before connecting batteries, to check that everything is connected correctly.

Step 3: Software

Upload the attached software.

For uploading or changing the code download and install Arduino Software.

Use a Crius FTDI Basic Breakout 5V USB to TTL 6-Pin Module for MWC MultiWii Lite module (other downloader could also work), to connect the PC to the Arduino.

Here is a YouTube video how the device works: