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:
Search
Products
Posts
Recent Post
-
STEM Robotics Workshop at Versova Welfare High School January 25, 2019
-
Robotics workshop in KP Ward Science Exhibition December 6, 2018
Customer Service
Extras
My Account
Partner
Shashi Kumar
Founder : Global Star Education Resources, Malaysia
H/P : 60123250147