Connection

Here we used LED as the indicator for motion detection, of course this could be placed bya buzzer or even a RElay to build a smart lighting systems.

  Arduino Uno R3Arduino Uno R3 Microcontroller

  16.00 JD                  Add to cart

  T1 (3mm) LED

T1 (3mm) Blue LED (select color)

   00.05 JD                 Add to cart

 PIR Motion Sensor

PIR Motion Sensor

   8.00 JD                   Add to cart

 


                                                                           


Code 

the code for tis is very simpel:

intsensorPin=2;
intled=13;
booleansensorValue=false;
//orcanputit
//intsensorValue=0;
voidsetup() 
{
//putyoursetupcodehere,torunonce: pinMode(13,OUTPUT); pinMode(sensorPin,INPUT);
}
  voidloop() 
{
 sensorValue=digitalRead(sensorPin); delay(50);
if(sensorValue==HIGH){
digitalWrite(13,HIGH);
delay(100);
}
else
{
digitalWrite(13,LOW);
delay(50);
}
 
 
 
 
}