How to Build a Simple Motion-Sensing Night Light with Arduino in 10 Minutes

Introduction

Building a motion-sensing night light with Arduino is a fun beginner electronics project that can be completed in under 10 minutes. The night light turns on automatically when it detects motion and turns off after a set amount of time.

This project is a great way to learn about Arduino, PIR motion sensors, and basic circuit building. In this guide, I will walk through all the steps required to build the motion-sensing night light from start to finish.

What You Will Need

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

Step 1: Connect the PIR Motion Sensor

The first step is to connect the PIR motion sensor to the Arduino. This allows the Arduino to detect when motion is present.

Follow these steps:

Step 2: Connect the LED

Next, we need to connect the LED:

Step 3: Install the Arduino Sketch

Now we need to upload the Arduino sketch that tells the night light how to function:

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

void setup() {

pinMode(ledPin, OUTPUT); // Set LED pin as output
pinMode(pirPin, INPUT); // Set PIR Out pin as input

}

void loop() {

int pirValue = digitalRead(pirPin); // Read PIR sensor value

if (pirValue == HIGH) { // If motion detected

digitalWrite(ledPin, HIGH); // Turn on LED
delay(5000); // Keep LED on for 5 seconds
digitalWrite(ledPin, LOW); // Turn off LED

}

}
```

Step 4: Power the Circuit

The last step is to power up the circuit:

That's it! You now have a fully functioning motion-sensing night light built with Arduino. This project can easily be expanded by adding more LEDs, tweaking the time durations, or triggering other devices.

Troubleshooting Tips

If your night light is not working, here are some troubleshooting tips:

With these simple tips, you should be able to get your DIY motion-sensing night light working quickly!