How to Build a Motion-Activated Night Light With an Arduino for Under 10$
Introduction
Building a motion-activated night light with an Arduino is an easy and affordable DIY electronics project. In this comprehensive guide, I will walk you through every step required to create your own motion-sensing night light for under $10.
A motion-activated night light can be useful in many situations. It allows you to navigate safely in low light conditions without needing to turn on all the lights. The light turns on automatically when motion is detected, and turns off after a set time when motion is no longer detected.
This project is beginner-friendly and can be completed in an afternoon using common electronic components. The end result is a customized night light you can place anywhere that needs hands-free lighting.
What You Will Need
To build the motion-activated night light, you will need:
-
Arduino Uno - The microcontroller board that will control the night light circuitry.
-
PIR motion sensor - Detects motion and triggers the Arduino to turn on the light.
-
LED light - The light source that will turn on when motion is detected. Any small LED will work.
-
220 ohm resistor - Limits current to the LED.
-
Breadboard - Used to easily prototype circuits.
-
Jumper wires - For connecting components to the Arduino and breadboard.
-
9V battery & battery clip - Power source for the Arduino.
-
Enclosure - A box to mount the finished night light in.
All of these components can be purchased for less than $10 total on websites like Amazon or electronic component suppliers like Adafruit and SparkFun. No soldering or advanced tools are required.
Circuit Diagram
The circuit diagram below shows how to connect the components to the Arduino board:
The PIR sensor, LED light, and resistor are connected to the power and ground pins on the Arduino. The digital OUT pin on the PIR connects to a digital input pin on the Arduino.
Setting Up the Arduino
-
Plug the Arduino into your computer using a USB cable.
-
Download the Arduino IDE software if you don't already have it. This allows you to program the Arduino board.
-
Open the IDE, then go to Tools > Board and select "Arduino Uno".
-
Next, go to Tools > Port and select the serial port associated with your Arduino.
-
Now you are ready to upload code to the Arduino.
Uploading the Code
I have written an Arduino sketch with code to control the motion sensing night light functions.
To upload it:
-
Copy the code from this sample sketch and paste it into a new sketch in the Arduino IDE.
-
Change the
pirPin
variable to match the input pin you used on your board. -
Verify the code, then upload it to your Arduino.
This will program the motion detection and LED lighting behavior.
Assembling the Hardware
Follow these steps to build the circuit:
-
Insert the PIR sensor, LED, and resistor into the breadboard.
-
Connect jumper wires according to the circuit diagram.
-
Plug the Arduino into breadboard power rails using jumper wires.
-
Connect the 9V battery to the power rails using the battery clip.
-
Mount the Arduino and breadboard into an enclosure.
-
Position the PIR sensor so it can detect motion outside the enclosure.
-
Turn on the power - your motion sensing night light is ready!
The light will turn on when the PIR sensor detects movement within its range. The code is set to keep the light on for 30 seconds after motion is detected before turning it off.
Customizing Your Night Light
Once you have the basic night light working, there are many ways to customize it:
-
Change the turn-on time and sensitivity of the PIR sensor.
-
Add more LEDs for brighter light.
-
Power it from a wall adapter instead of a battery.
-
Trigger a warning sound or signal when motion is detected.
-
Create multiple night lights that synchronize together.
-
Add a light sensor so it only turns on in dark conditions.
The options are endless - this project is a great starting point for more advanced Arduino experiments!
With just a little time and less than $10 of supplies, you can create your own motion-controlled night light. This handy gadget provides automated lighting wherever you need it.