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

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

Introduction

Building a simple motion-activated night light using an Arduino is a great weekend project that can be completed in under 10 minutes. This easy-to-build gadget will turn on a small LED light automatically whenever motion is detected in a dark room.

With just a few common components, you can create a handy little device that's perfect for a hallway, bedroom, or even the bathroom. Motion sensor night lights are useful for navigating dark spaces safely without turning on bright overhead lighting.

In this guide, I'll walk through the entire process step-by-step, from the parts you'll need to upload the code. With the right components and a basic understanding of Arduino, you'll have your own DIY motion-sensing night light set up in no time!

What You'll Need

To build the Arduino night light, you'll need the following components:

Circuit Diagram

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

The PIR motion sensor has three pins - VCC, GND, and OUT. The LED and resistor connect to Arduino pin 3. Make sure the LED's positive leg connects to pin 3 through the resistor.

Code

The Arduino code for this project simply turns the LED on when motion is detected. Here's the full code to upload:

```cpp
int ledPin = 3; // LED on pin 3
int pirPin = 2; // PIR on pin 2

void setup() {

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

}

void loop() {

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

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

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

} else {

digitalWrite(ledPin, LOW);       // Else turn off LED

}

}
```

This initializes the pins, reads the PIR sensor value, and turns the LED on or off based on motion.

Putting It Together

Follow these steps to assemble your motion-sensing night light:

  1. Insert the Arduino, PIR sensor, LED, resistor, and jumper wires into the breadboard.

  2. Connect the components according to the circuit diagram using jumpers.

  3. Upload the Arduino code to your board.

  4. Power the Arduino with a 9V battery or cable.

  5. Put the breadboard and Arduino in a dark room and wave your hand over the PIR to test. The LED should turn on when motion is detected!

Adjust the PIR sensitivity and LED brightness to suit your needs. Install the device in a hallway or room where you want motion-activated lighting at night.

Conclusion

Building your own Arduino night light with motion sensor is an easy electronics project that can be completed in just 10 minutes. With minimal components, it will provide automatic lighting when you need it.

This guide covered the key steps including the parts required, circuit connections, code, and assembly. With the right components, wiring, and code upload, you'll have a fully functioning motion-sensing light perfect for dark halls, bedrooms, and more.

So grab an Arduino and a few components, follow the instructions, and you'll be able to set up your own automated night light in no time!