info@maverickden.com
+91 9867381971 (India)

PIR MOTION SENSOR

In this tutorial we will show you how PIR Motion Sensor Works  with Arduino UNO / Nano.

COMPONENT Used:

SR NO COMPONENT NAME QUANTITY
1 Arduino Board (Uno or Nano) 1
2 BreadBoard (Optional) 1
3 PIR Motion Sensor 1
4 Jumper Cable (Male to Female) 1 set
5 LED (5MM) 1

 

Schematic Diagram :

Source Code:

int led=13;

//attached to

int sensor= 2;

//attached to

int state=LOW;

//Detected

int val=0;

//sensor status(value)

 

void setup() {

// put your setup code here, to run once:

pinMode(led,OUTPUT);

pinMode(sensor,INPUT);

Serial.begin(9600);

}

 

void loop() {

// put your main code here, to run repeatedly:

val=digitalRead(sensor);

if (val==HIGH)

{

digitalWrite(led,HIGH);

delay(100);

if(state==LOW)

{

Serial.println(“Motion detected”);

state=HIGH;

}

}

else

{

digitalWrite(led,LOW);

delay(200);

if(state=HIGH)

{

Serial.println(“Motion detected”);

state=LOW;

}

}

}

Video:

Comments are closed.