How to Build a Simple Arduino Motion-Sensing Night Light for Under $15

Building a motion-sensing night light with an Arduino is an easy and inexpensive DIY electronics project. With just a few common components, you can make a useful gadget to light up a dark room when motion is detected. Here is a step-by-step guide on how to build your own Arduino motion-sensing night light for under $15.

Shopping List

Here are the components you'll need:

So for around $15-$20, you can get all the key components needed. You may also want to get a small cardboard enclosure, some hot glue, and tape to package it all up nicely.

Circuit Diagram

Here is the circuit diagram showing how to connect all the components:

How to Build a Simple Arduino Motion-Sensing Night Light for Under

The PIR sensor, Arduino, and LED lights are all powered by the 5V supply. The sensor is connected to digital pin 2 on the Arduino. The positive lead of the LED strip connects to digital pin 9, and the negative lead goes through a resistor back to ground.

Setting up the Sensor

The HC-SR501 PIR motion sensor allows you to detect movement up to 20 feet away. It has 3 pins - VCC for power, OUT for the digital output, and GND for ground.

To connect it:

The sensor can be configured using the potentiometer and jumper. Turn the potentiometer counter-clockwise for maximum sensitivity up to 20 feet. Leave the jumper on "L" mode for continuous detection when motion is sensed.

Uploading the Code

Next, you need to upload this Arduino code to your board:

```c++
const int motionSensor = 2; //input pin for PIR sensor
const int ledPin = 9;//output pin for LED strip lights

void setup() {
pinMode(motionSensor, INPUT); //set motion sensor pin as input
pinMode(ledPin, OUTPUT); //set LED pin as output
}

void loop(){
if(digitalRead(motionSensor) == HIGH){ //if motion detected
digitalWrite(ledPin, HIGH); //turn on LED
}
else{
digitalWrite(ledPin, LOW); //else turn off LED
}
}
```

This initializes the pins, reads the sensor continuously, and turns the LED on when motion is detected. Feel free to customize the light behavior here.

Setting up the LEDs

LED strip lights are very easy to connect. Simply plug the positive lead into Arduino pin 9, and the negative lead into the ground rail on the breadboard. Add a resistor between the negative lead and ground to prevent excess current.

Use tape or glue to secure the LED strip in place around the edge of a shelf, cabinet, or doorway - wherever you want the light. The motion sensor should point towards the area you want to detect motion.

And that's it! Plug in the power supply and your DIY motion-sensing night light should turn on automatically when you walk by. You can customize it by adding more LEDs, sensors, or modifying the code. It's a fun beginner Arduino project that costs less than $15!