How to Build a Simple Motion-Activated LED Night Light with an Arduino for Under $15
I decided to build a simple motion-activated LED night light using an Arduino board to turn the lights on automatically when I walk into a room. This project was inexpensive to put together and works great for lighting up hallways or other spaces as needed. Here is a step-by-step guide on how I built it for under $15.
Shopping List
Here are the components I used:
-
Arduino Uno board - The brains of the operation. I used an official Arduino Uno, but any Arduino-compatible board will work.
-
PIR motion sensor - Detects motion and signals the Arduino to turn on the lights. I used the HC-SR501 model.
-
LED strip lights - I used a 16.4 foot roll of flexible LED strip lights with 300 LEDs. Make sure to get the kind with a sticky back.
-
Solid core wire - For connecting the components. Regular hookup wire works fine.
-
DC power jack - To connect a DC power adapter to power the Arduino.
-
Barrel jack adapter - For connecting the DC power jack to the Arduino.
-
9V 2A power adapter - To power the LED strip and Arduino. The amperage depends on how many LEDs you have.
-
Breadboard - Makes it easy to connect components. I used a half-size board.
-
Jumper wires - For hooking everything up on the breadboard.
-
Cardboard box (optional) - I mounted my circuit inside a cardboard box, but you can also leave it out in the open.
Circuit Assembly
Connect the PIR Motion Sensor
The PIR motion sensor has three pins - ground, signal, and power. I connected the ground pin to the Arduino's GND pin, the signal pin to Arduino pin 2, and the power pin to 5V. This supplies power to the sensor while allowing it to communicate motion detection to the Arduino on pin 2.
Connect the LED Strip
The LED strip has four pins - ground, data in, clock, and power. I connected ground to GND, data in to Arduino pin 6, clock to Arduino pin 7, and the power pins directly to the positive and negative terminals on the DC barrel jack. This allows the Arduino to control the LEDs.
Supply Power
I connected a 9V DC power adapter to the DC barrel jack adapter and plugged that into the Arduino's power pins to supply power to the whole circuit. Make sure the power adapter can provide enough current for all your LEDs.
Upload the Arduino Sketch
With all the hardware connected, I uploaded a simple Arduino sketch to make the magic happen. The sketch monitors the PIR sensor pin and turns the LED strip on when motion is detected. The LEDs fade out after 30 seconds.
Mounting Options
I mounted all the components inside a cardboard box, but you can also mount the Arduino, breadboard, and DC jack to a back panel or inside an enclosure. For the PIR sensor and LEDs, I used double-sided tape to adhere them in place. Make sure no wires will get pinched or crimped when closing the box.
Installation Tips
Position the PIR sensor so it has a good view of the area you want to detect motion in. Try to aim it away from windows and objects that might blow around and set it off.
For the LED strip, you can carefully peel off the adhesive backing and stick it under cabinets, shelves, or anywhere you want illumination. I installed mine behind a cabinet to shine down on the counter.
Use cable clips and staples to neatly route any visible wires. Make sure wires going into the box through holes or cracks are protected from snagging.
Usage and Customization
The LEDs will now automatically turn on when the PIR sensor detects movement! I have mine set up to turn on when I walk into the kitchen at night.
Some ways you can customize this project include:
-
Using a different sensor like an ultrasonic or microwave motion detector
-
Adding a photoresistor to only turn on at night
-
Using a relay module for controlling higher power lights, like bulbs
-
Adding a switch to manually turn the lights on and off
-
Using a color changing RGB LED strip and programming cool patterns
Let me know if you build your own motion-activated night light! I'm happy to help if you need any guidance with the DIY electronics and programming. Have fun and stay safe.