This is a simple motion sensor project using Arduino. A 220V AC lamp is connected to a 5V relay and the relay is activated once the motion sensor senses motion and sends a signal to the Arduino.

List of materials

  • Arduino Uno ( Rev 3 )
  • Sensor ( PIR )  HC-SR501
  • Keyes SRD-05VDC-SL-C Relay Module or any 5V relay module
  • Socket
  • Bulb ( Incandescent lamp )
  • Suitable wires and jumpers ( thicker wires for a lamp connection, such as 1.5mm FiOS 2 ).
  • A breadboard or a protoboard to solder.

If you have never used a relay, you are recommended to read this article: How to use a relay

The code

const int negativeRELE = 10; 
const int pinPIR = 4; 

void setup () { 
  pinMode (pinRELE, OUT); 
  pinMode (pinPIR, INPUT); 
} 

void loop () { 
  int valued = digitalRead (pinPIR); 
  if (value == HIGH) { 
    digitalWrite (pinRELE, HIGH); 
    delay (5000); 
    digitalWrite (pinRELE, DOWN); 
  } 
}

Running the Circuit

The project shown below has been added with an LDR/photoresistor. This gives the project an additional feature of responding to darkness and light. To test the circuit, simply move the front of the sensor to be triggered.


Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.