How to Build a Motion-Sensing Night Light With Just a Few Electronics Parts

How to Build a Motion-Sensing Night Light With Just a Few Electronics Parts

Building a motion-sensing night light is a fun electronics project that can be completed in just a few steps with basic components. Here is a step-by-step guide to building your own motion-activated night light using common electronics parts.

What You Will Need

To build the motion-sensing night light, you will need the following components:

Circuit Diagram

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

The PIR sensor, LED, and resistor are connected to the Arduino board. The 9V battery powers the Arduino.

Assembling the Circuit

Step 1) Connect the PIR motion sensor to the Arduino by connecting VCC to 5V, GND to GND, and the OUT pin to digital pin 2.

Step 2) Connect the LED through the 220 ohm resistor to Arduino pin 13. The resistor is needed to limit the current through the LED.

Step 3) Connect the 9V battery to the Arduino's Vin pin and GND pin using the battery clip. Make sure the red wire goes to Vin and the black wire goes to GND.

Step 4) Install the Arduino IDE on your computer and connect the Arduino board using the USB cable.

Loading the Code

With the circuit assembled, it's time to load the Arduino sketch. This code tells the Arduino to monitor the PIR sensor and turn the LED on when motion is detected.

```c++
// Motion-Sensing Night Light

int pirPin = 2; // PIR connected to pin 2
int ledPin = 13; // LED connected to pin 13

void setup() {

pinMode(pirPin, INPUT);
pinMode(ledPin, OUTPUT);

}

void loop() {

if (digitalRead(pirPin) == HIGH) {

digitalWrite(ledPin, HIGH); // Turn LED ON

}
else {

digitalWrite(ledPin, LOW); // Turn LED OFF

}

}
```

Copy this code and upload it to the Arduino board.

Testing and Using the Night Light

After uploading the code, test the night light by waving your hand in front of the PIR motion sensor. The LED light should turn on when motion is detected.

To turn the night light into a finished project:

And that's it! With just a few basic electronic parts, you can build your own motion-sensing night light with Arduino.