How to Build a Simple Motion-Sensing Night Light With an Arduino

Introduction

Building a motion-sensing night light with an Arduino is a fun electronics project that can be completed in an afternoon. The night light turns on automatically when it detects motion and turns off after a set time with no motion detected.

This project is relatively simple, making it a great beginner Arduino project. With just a few electronic components and some basic coding skills, you can create a handy gadget to light your way in the dark.

In this guide, I will walk you through the full process of creating your own motion-sensing night light with an Arduino step-by-step.

What You'll Need

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

You'll also need the Arduino IDE installed on your computer to write and upload the code.

Circuit Diagram

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

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

Step-by-Step Build Instructions

Follow these steps to assemble the motion-sensing night light circuit:

1. Insert the PIR sensor into the breadboard

Place the PIR sensor on the breadboard spanning the center channel. Make sure the flat side faces left with the lens on top.

2. Connect the PIR sensor to the Arduino

Use jumper wires to connect the PIR sensor to the Arduino as follows:

3. Add the LED and resistor

Insert the LED into the breadboard and the 220 ohm resistor in series to one leg. Connect the free leg of the resistor to Arduino pin 3.

4. Connect the 9V battery

Use the 9V battery clip to provide power to the Arduino board through the Vin and GND pins.

5. Upload the Arduino code

With all components wired up, upload the sketch provided below to the Arduino board.

6. Enclose in a housing

Place the breadboard and Arduino board into an enclosure, bulb facing outward. Your motion-sensing night light circuit is now complete!

Arduino Code

```cpp
// Motion-sensing Night Light

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

void setup() {

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

}

void loop() {

if (digitalRead(pirPin) == HIGH) {

digitalWrite(ledPin, HIGH); // Turn ON LED
delay(10000); // Keep LED on for 10 seconds
digitalWrite(ledPin, LOW); // Turn OFF LED

}

}
```

This code reads the PIR sensor pin and turns the LED on for 10 seconds when motion is detected.

Using the Motion-Sensing Night Light

Once assembled and programmed, using the night light is easy.

Simply turn on the power switch and the night light will activate when it senses motion. The LED will illuminate for 10 seconds then turn off automatically.

Place the night light in any room or hallway where you need hands-free lighting at night. Adjust the timeout delay as needed to keep the light on for shorter or longer periods.

Customizing and Improving the Build

There are many ways to customize and expand this basic motion-sensing night light:

So once you have the basic build working, feel free to tweak it and add features to better suit your needs. The possibilities are endless!

Conclusion

Building your own motion-sensing night light with an Arduino is an easy electronics project that provides practical lighting automation. It's inexpensive to put together and highly customizable.

With the components, code, and instructions provided in this guide, you should now have all the information you need to get started creating your own Arduino-based motion-sensing night light that provides hands-free lighting when you need it.