Introduction
Installing a motion-activated light in your stairwell is a great way to illuminate the stairs safely without having to turn on switches every time you use them. With an Arduino microcontroller, a few electronic components, and basic programming skills, you can build your own motion-sensing light easily.
In this guide, I will walk you through a simple DIY project to create a motion-activated light for your stairwell using an Arduino Uno board. We will go over:
- The components you need
- How to assemble the circuit
- Programming the Arduino
- Installing the motion-sensor light
So if you want to upgrade your stairwell lighting in a fun electronics project, read on!
Components Needed
To build the motion-activated stairwell light, you will need the following components:
- Arduino Uno - The microcontroller board that will control the circuit.
- PIR motion sensor - Detects motion and sends a signal to the Arduino.
- Relay module - Switches the light on/off based on Arduino output.
- LED light strips - For illuminating the stairs. Get RGB strips to control light color.
- Jumper wires - For connecting the components.
- 9V battery - Powers the Arduino.
- Breadboard - To prototype the circuit.
- 220Ω resistor - For the LED strip.
- Hook-up wire - For installing the final circuit.
- Plastic housing - To mount the components.
This simple list of components is all you need to sense motion and activate LED lights automatically using the Arduino!
Assembling the Circuit
We will first prototype the motion-activated light circuit on a breadboard before installing it permanently.
1. Connect the PIR motion sensor
-
Place the PIR sensor on the breadboard and use jumper wires to connect the power and ground pins to 5V and GND pins on the Arduino.
-
Connect the output pin of the PIR to Arduino digital pin 2. This sends motion signals to the Arduino.
2. Connect the relay module
-
Place the relay module on the breadboard. Connect the JD-VCC pin to 5V and JD-GND to GND.
-
Connect the IN pin to Arduino pin 3. This will switch the relay ON/OFF.
3. Connect LED light strips
-
Connect the positive (+) and negative (-) wires of the LED strips to the NO and COM pins of the relay module.
-
Add a 220Ω resistor between the + and - wires to protect the LEDs.
And that completes our motion-activated light circuit! The PIR will sense movement and signal the Arduino, which will trigger the relay to switch on the LED strips.
Programming the Arduino
Now let's program the Arduino to activate the stairwell light when motion is detected.
1. Initialize the motion sensor pin
We'll call the PIR sensor pin motionSensor
:
cpp
int motionSensor = 2;
2. Initialize the relay control pin
The relay control pin is relay
:
cpp
int relay = 3;
3. Set LED light status variable
We need a boolean variable to store whether the light is ON or OFF:
cpp
bool lightOn = false;
4. Check for motion in loop()
Use an if
statement to check the PIR sensor pin and switch the light:
```cpp
if (digitalRead(motionSensor) == HIGH) {
if (lightOn == false) {
digitalWrite(relay, HIGH);
lightOn = true;
}
} else {
if (lightOn == true) {
digitalWrite(relay, LOW);
lightOn = false;
}
}
```
This code turns the light ON when motion is detected and OFF again after some time. Upload it to your Arduino!
Installing the Motion-Sensing Light
Once the circuit is tested and programmed, you can install the motion-activated light in the stairwell permanently:
-
Solder or securely connect all the components and wires.
-
Mount the Arduino, PIR sensor, relay module, and wires safely in a plastic housing.
-
Affix LED strip lights under the stair edges to illuminate each step.
-
Make sure no connections are loose or exposed.
-
Power the Arduino using the 9V battery, USB, or DC jack.
-
Mount the housing on the stairwell wall and test the motion-sensing light.
And that's it! Your DIY motion-activated stairwell light using Arduino is ready. Walk up the stairs and watch the LEDs turn on automatically.
Some ideas to enhance the project:
- Set LED color using RGB strips and Arduino code.
- Add a potentiometer to adjust light brightness.
- Use a sound sensor to also trigger the lights on.
With Arduino, electronics components, and basic coding, you can build creative motion-sensing lights for your home stairwells, hallways, or rooms!