Hi everyone,
I am vigneshraja. Here I presented the code for interfacing arduino UNO with PIR Motion Sensor like shown in above video.
I am vigneshraja. Here I presented the code for interfacing arduino UNO with PIR Motion Sensor like shown in above video.
Code:
const int PIRPin = 2;
const int LEDPin = 13;
int PIRState = 0;
void setup() {
pinMode(PIRPin,INPUT);
pinMode(LEDPin,OUTPUT);
Serial.begin(9600);
}
void loop() {
PIRState = digitalRead(PIRPin);
if(PIRState == HIGH)
{
digitalWrite(LEDPin,HIGH);
Serial.println("Motion detected!");
}else
{
digitalWrite(LEDPin,LOW);
}
}
Thank you for reading
Comments
Post a Comment