Introduction
Having a motion activated night light can be incredibly convenient and helpful. Instead of fumbling for a light switch in the dark or having a bright light on all night, a motion activated night light turns on automatically when it detects movement. This allows you to easily navigate in the dark when needed, without keeping lights on unnecessarily.
In this guide, I will show you how I built a motion activated night light using an Arduino microcontroller and basic electronic components for less than $20. With just a bit of tinkering, you can create your own useful night light gadget on a budget.
Parts and Tools Needed
To build the motion activated night light, you will need the following parts and tools:
Parts
- Arduino Uno board ($5-$10)
- PIR motion sensor ($2-$5)
- LED light strip or bulb ($3-$10)
- Breadboard ($5)
- Jumper wires (couple dollars)
- 9V battery and clip ($5)
Tools
- Soldering iron and solder
- Wire cutters/strippers
- Hot glue gun
Total cost: Less than $20
The Arduino microcontroller acts as the brains of the operation, while the PIR sensor detects motion and triggers the LED light strip to turn on. The battery provides portable power.
Circuit Design
The circuit for the motion activated night light is very simple. Here is how to connect the components:
- Connect the PIR sensor to the 5V and GND pins on the Arduino
- Connect the signal pin on the PIR to a digital input pin on the Arduino (such as pin 2)
- Connect the positive lead of the LED strip to a digital output pin on the Arduino (such as pin 13)
- Connect the negative lead of the LED strip to a GND pin on the Arduino
- Connect the positive terminal of the battery pack to the Vin pin on the Arduino
- Connect the negative terminal of the battery pack to the GND pin on the Arduino
This completes the basic circuit. The PIR sensor will detect motion and send a HIGH signal to the Arduino on the digital input pin. The Arduino code (covered next) will turn the digital output pin HIGH, lighting up the LED strip.
Arduino Code
The Arduino code for this project is very simple as well. Here is an overview of the code:
```cpp
// Declare PIR pin and LED pin
const int PIR_PIN = 2;
const int LED_PIN = 13;
// Variables
int pirState = LOW;
void setup() {
pinMode(PIR_PIN, INPUT);
pinMode(LED_PIN, OUTPUT);
}
void loop() {
// Read PIR state
pirState = digitalRead(PIR_PIN);
// If motion detected (HIGH) turn LED on
if (pirState == HIGH) {
digitalWrite(LED_PIN, HIGH);
}
else {
digitalWrite(LED_PIN, LOW);
}
}
```
The code declares pins for the PIR sensor and LED strip, reads the PIR state each loop, and turns the LED on when motion is detected. This basic code is all you need to create the motion sensing functionality.
Construction
With the circuit complete and code uploaded to the Arduino, the motion sensing night light is nearly finished!
Follow these remaining steps:
- Mount the PIR sensor, Arduino, and breadboard into an enclosure or box. I used a cardboard box.
- Affix the LED strip or bulb wherever you want the light mounted using hot glue.
- Power on the Arduino using the 9V battery pack.
Once constructed, you now have a fully functioning motion activated night light for under $20!
The light will automatically turn on when the PIR sensor detects movement within its range. The sensitivity and direction can be adjusted by repositioning the PIR sensor.
Conclusion
Building your own motion activated night light with an Arduino is an easy electronics project that anyone can tackle on a budget. In just a few steps, you can construct a handy gadget to light up dark rooms and hallways automatically.
Customize the project by using different enclosures, sensors, and lighting. Consider adding features like light color or brightness control. The possibilities are endless!
Let me know if you have any other questions about constructing your own motion sensing night light with an Arduino!