Arduino – PIR Sensor (HC-SR501)

PIR Sensors (Passive Infrared) are the standard sensors used for motion detection. They offer a wide field of view and are easy to configure, but offer only HIGH/LOW output and are not overly accurate.

Functional Parts in the Project:

#define pirSensor 8

int reading;

void setup() {

  pinMode(pirSensor, INPUT);

  Serial.begin(9600);

}

void loop() {

  reading = digitalRead(pirSensor);

  if (reading == HIGH) {
    Serial.println("Motion");
  } else {
    Serial.println("0");
  }

}

Be the first to comment

Leave a Reply