Arduino Motion Detection Light




About: i am gabriel ,from chennai,tamilnadu. I create new gadgets to change the Future


Hi, this is my new Arduino Motion Detection Light. It is powered by an 9v supply for the arduino and 5w for light. If a man or an animal pass through the PIR sensor, it detects and will start the relay(as the light turns on). If there is no detection, then it will stop the relay(as the light turns off). You can also attach to walls with the hanging tie.This project is very usefull in our life. You can attach it to your room or bathroom or in a bedroom........


1.A Wooden Sheet

2.A bulb (0.5watts or 7watts)

3.A bulb holder

4.arduino board

5.a 5v Relay

6.a 9V adapter

7.a motion sensor(pir)

8.Jumper cables and 2 meter double wire(twisted)

9.screws(which can go through arduino and relay holes)

Step 2: Connect the PIR Sensor to the Arduino

1.connect the VCC pin to the 3.3v.

2.connect the GND pin to the ground.

3.connect the OUT pin to the digital pin 4.

Step 3: Connect the 5v Relay to the Arduino

1.Connect the GND pin to the ground.

2.Connect the IN1 pin to the digital pin 8.

3.Connect the VCC pin to the 5v.

Step 4: Connect the Bulb

Connect the -ve end of the current to the NC slot.
Connect the -ve end of the bulb to the NO slot.
Now connect the positive of the bulb to the positive of the current.

Step 5: Coding....

copy and paste to the IDE.

int irmotionPin = 4; // Pin of IR Motion Sensor

int relayPin = 8; // Pin of Relay Module

void setup(){ Serial.begin(9600);

pinMode(relayPin, OUTPUT);

// Set Pin connected to Relay as an OUTPUT

digitalWrite(relayPin, LOW);

// Set Pin to LOW to turn Relay OFF }

void loop(){

while (digitalRead(irmotionPin) == HIGH)

{ // If Motion detected

digitalWrite(relayPin, HIGH);

// Turn Relay ON

Serial.println("Relay is ON");


digitalWrite(relayPin, LOW);

// Turn Relay OFF Serial.println("Relay is OFF");

delay(500); }

Step 6: WARNING!!!!!

Its very dangerous beacuse of high voltage AND you might get shocked.So recheck that everything is connected properly and correctly.After doing all , PLUG IN YOUR CIRCUIT. FIRST THE LIGHT TURNS ON AND OFF. THEN YOUR CIRCUIT WILL WORK.if It dosnt, please comment, so that i can solve it.

Step 7: Attach Everything to the Wooden Sheet With the Screws.

Step 8: You Are Done.



    • Classroom Science Contest

      Classroom Science Contest
    • Fandom Contest

      Fandom Contest
    • Woodworking Contest

      Woodworking Contest

    3 Discussions


    19 days ago

    I copy and paste the code above and get the following errors:

    C:\Users\garre\Documents\Arduino\sketch_apr30e\sketch_apr30e.ino: In function 'void setup()':
    sketch_apr30e:15:12: error: a function-definition is not allowed here before '{' token
    void loop(){
    sketch_apr30e:33:13: error: expected '}' at end of input
    delay(500); }
    exit status 1
    a function-definition is not allowed here before '{' token

    Any help would be appriciated, thank you!


    Question 6 months ago on Step 6

    Thanks for a great tutorial. I have been trying to build an Arduino-HC-SR501-relay circuit that will turn on my den light, then keep it on for ten minutes after motion is detected. If I have moved before the 10 minutes are up, the light stays on and does not switch off, even momentarily. What delay should I set - I presently have 600000 delay if motion is detected, but the light will shut off momentarily once the 10 minutes are up. How can I avoid this? Thanks again.


    Question 11 months ago on Step 2

    Can I use multiple (3 to be exact) PIRs? I want to have a sensor on each side, and at the foot, of my bed. How would I go about wiring them?