How to Build an Arduino-Powered Motion Sensor Night Light for Under $15
Introduction
Building an Arduino-powered motion sensor night light is an easy and fun electronics project that can be completed in an afternoon for under $15. With just a few common components, you can create a useful night light that turns on automatically when it detects motion in a dark room.
In this comprehensive guide, I will walk through each step required to build this DIY motion-sensing night light using an Arduino microcontroller board. I will cover:
The Materials and Tools Needed
- Arduino Uno board
- PIR motion sensor
- LED light strips or bulb
- Breadboard
- Jumper wires
- 9V battery & battery clip
- enclosure (optional)
The Circuit Design and Connection
- Overview of each component and its role
- Schematic diagram of the circuit
- Instructions for connecting the components on a breadboard
The Arduino Sketch and Code
- Downloading the Arduino IDE
- The code to get the motion sensor and LED working
- Uploading code to the Arduino
Assembling the Hardware
- Mounting the components
- Powering the Arduino and breadboard
- Adding a case (optional)
Applications and Future Enhancements
- Ideas for using your new motion-sensing night light
- Possible upgrades and additions to the project
By the end of this guide, you will have gained both the knowledge and tools to create your own automated Arduino night light that turns on when needed. The skills you learn can also be applied to more advanced Arduino projects in the future.
The Materials and Tools Needed
To build the Arduino motion-sensing night light, you will need the following components:
-
Arduino Uno Board - This is the microcontroller board that will run the code and control the circuit. It can be purchased for around $10.
-
PIR Motion Sensor - The passive infrared (PIR) sensor detects motion up to 20 feet away. They are very affordable at $2-5.
-
LED Light Strips/Bulb - For the light source, you can use LED strips or a simple bulb. Look for ones around 300 lumens or more.
-
Breadboard - Used to easily connect components. A small $5 breadboard will suffice.
-
Jumper Wires - You'll need male-to-male jumper wires to connect the Arduino and breadboard. Get a variety pack of lengths.
-
9V Battery - Used to power the Arduino board via a battery clip connector. Rechargeable 9V work great.
-
Battery Clip - Connects a 9V battery to the Arduino's power jack. Can be found for around $2.
-
Enclosure (Optional) - A plastic box to enclose the project's circuitry. Approx $5.
For tools, you will need:
- A computer for programming the Arduino
- Wire cutters and wire strippers
- A soldering iron may be handy for securing connections
- Double-sided tape or velcro to mount components
That covers the key components and tools needed for this budget Arduino night light project. Now let's look at how to put it all together.
The Circuit Design and Connection
The circuit for this motion-sensing night light is simple, with just a few key components connected to the Arduino board:
Here is an overview of each part's role in the circuit:
-
The Arduino acts as the brain, running the code to control the night light.
-
The PIR sensor detects movement and triggers the Arduino to turn on the light.
-
The LED light source turns on when activated by the Arduino's output pin.
-
The 9V battery provides power to the Arduino through the Vin pin.
To build the circuit:
-
Connect the PIR sensor to +5V, GND, and a digital pin on the Arduino.
-
Connect the positive leg of the LED light to a digital output pin. Connect the negative leg to GND.
-
Connect the 9V battery to the Vin pin and GND pin of the Arduino via the battery clip.
-
Use jumper wires to make all connections. Follow the circuit diagram.
-
Mount the PIR sensor, LED light, and breadboard in a case using tape/velcro.
Take your time making the connections - referring to the circuit diagram to double-check each wire. Once assembled, we can move on to programming the Arduino brain of our night light creation.
The Arduino Sketch and Code
To program the Arduino Uno board, you will need to first download the Arduino IDE software on your computer. This open-source software allows you to write code and upload it to any Arduino board.
Downloading the Arduino IDE
Here are the steps to install the Arduino IDE:
- Go to www.arduino.cc
- Click to download the Windows, Mac, or Linux software depending on your computer.
- Open the downloaded file and follow the steps to install the Arduino IDE.
- Once installed, open the Arduino app on your computer.
With the IDE ready, you can now write and upload the sketch for the motion-sensing night light.
The Arduino Code
The code for this project is relatively simple. It includes:
- Setting pin numbers for the PIR sensor and LED light
- Initializing variables
- Void loop() that continuously checks the PIR sensor's state
- Turning the LED on when motion detected
- Delay to keep LED on for 60 seconds after last motion
Here is the full Arduino sketch:
```cpp
// Motion Sensor Night Light Code
// PIR Sensor pin
int pirPin = 2;
// LED pin
int ledPin = 13;
// Variables
int pirValue; // PIR status
int ledState = LOW;
void setup() {
// Set LED pin as output
pinMode(ledPin, OUTPUT);
// Set PIR pin as input
pinMode(pirPin, INPUT);
}
void loop(){
// Read PIR state
pirValue = digitalRead(pirPin);
// If motion detected
if (pirValue == HIGH) {
// Turn on LED
digitalWrite(ledPin, HIGH);
// Delay 60 seconds
delay(60000);
// Turn off LED
digitalWrite(ledPin, LOW);
}
}
```
This code continuously checks the PIR sensor. When motion is detected, it triggers the LED to turn on for 60 seconds before turning off again. Pretty simple!
Uploading the Code
To get this sketch running on the Arduino:
- Connect the Arduino to your computer via USB cable.
- In the Arduino IDE, select the board type (Arduino Uno) and COM port it is connected to.
- Copy the code and paste it into a new sketch in the IDE.
- Click the "Upload" button to compile and upload to the board.
Once uploaded, the code will run automatically on the Arduino. Now it's time to put it all together!
Assembling the Hardware
With the circuit complete and code uploaded, the final step is assembling the hardware components for the motion-activated night light.
Mounting the Components
It's best to mount the components in an enclosure to protect the electronics. Here are some tips:
-
Mount the Arduino board, breadboard, PIR sensor, and LED light strip/bulb inside a plastic enclosure using velcro or double-sided tape.
-
Position the PIR sensor on one side so it can detect motion outside the box.
-
Angle the LED light to point outside the enclosure as well.
-
Neatly secure all the wires with zip ties or tape.
If you don't have an enclosure, simply mounting the components securely on a piece of cardboard or wood will also work.
Powering the Arduino
To power the Arduino for this project, connect a 9V battery to the Vin and GND pins using a 9V battery clip adapter.
Make sure the battery clip wires provide a firm connection. You can solder them directly to the Arduino pins for a permanent power source.
For portable use, a 9V battery will provide hours of usage. You can also plug the Arduino into a USB power adapter or USB battery pack for unlimited run time.
Adding a Case (Optional)
For a polished finished product, you can 3D print or hand-make a custom case. Some ideas:
-
3D model a snap-fit two-piece enclosure using FreeCAD, Tinkercad or an online 3D modeling tool.
-
Craft a case from cardboard, wood, plastic sheets, etc.using simple tools.
-
Design a mounting plate or stand for desktop use.
With the electronics secured and wired up inside the case, your DIY motion-sensing night light is complete!
Applications and Future Enhancements
You now have an automated Arduino-based night light that turns on when it detects movement in low light.
How to Use Your New Night Light
There are many handy applications for this responsive LED light:
-
Place it in a hallway, stairway, or room to illuminate the area at night when someone walks by.
-
Use it as a novelty "party" light that guests can trigger.
-
Install it on a porch or deck to automatically turn on when you or visitors arrive.
-
Let it provide automatic lighting for a child who gets up in the middle of the night.
The possibilities are endless for this useful gadget!
Possible Upgrades and Additions
Here are ideas for enhancing your Arduino motion-sensing night light:
-
Add an RTC module to make the light turn on and off at set times.
-
Install multiple LED strips for wider illumination.
-
Use a photoresistor to prevent triggering in daylight.
-
Add Wi-Fi and control the light remotely via smartphone.
-
Connect it to IFTTT to integrate with other smart devices.
The skills you learned creating this starter project will enable you to expand it and create more advanced Arduino designs. Just let your creativity guide you!
Conclusion
Constructing this nifty automated night light with Arduino teaches useful skills in electronics, programming, and DIY engineering. For under $15 in parts, you can build your own motion-sensing gadget from scratch.
The simple circuit uses just an Arduino, PIR sensor, LED light, breadboard, and a few basic components. With easy-to-learn Arduino code, the light turns on whenever the sensor detects movement in low light.
Mounting it in a custom enclosure produces a polished, finished product. And there are tons of applications for this auto-sensing LED light in any home, office, or workspace.
This project also provides a foundation for learning more advanced Arduino programming and electronics. You can now take the skills to the next level and create more complex interactive devices. The possibilities are wide open when tapping into the power of the Arduino!