Muhammad_Munir
Published © GPL3+

PIR sensor Interface with Arduino

PIR sensor Interface with Arduino

IntermediateFull instructions provided1,085
PIR sensor Interface with Arduino

Things used in this project

Story

Read more

Code

Arduino UNO interface PIR sensor

Arduino
const int PIR_Sensor = 2;     // the number of the PIR_Sensor pin
const int ledPin =  13;      // the number of the LED pin
int Motion_State = 0;         // variable for reading the Motion status

void setup() {
  pinMode(ledPin, OUTPUT);    // initialize the LED pin as an output:
  pinMode(PIR_Sensor, INPUT); // initialize the PIR_Sensor pin as an input:
}

void loop() {
  
  Motion_State = digitalRead(PIR_Sensor);  // read the state of the PIR_Sensor value:
  if (Motion_State == HIGH) {   // check if the Motion_State is High.
  digitalWrite(ledPin, HIGH); // turn LED on:
  delay(10000);
  } else {
    
    digitalWrite(ledPin, LOW);  // turn LED off:
  }
}

Credits

Muhammad_Munir
79 projects • 56 followers
I am Arduino programmer, also expertise in ESP32 and 8266 wifi modules.

Comments