Lisleapex Blog
Published

How to Connect PIR Sensor With Arduino Microcontroller

In this project, we will learn how to interface a PIR sensor with a microcontroller like Arduino.

BeginnerWork in progress2 hours85
How to Connect PIR Sensor With Arduino Microcontroller

Things used in this project

Story

Read more

Schematics

arduino_and_pir_V480TMGGPG.png

Code

Arduino

Arduino
void setup() {

  pinMode(2, INPUT); //Pin 2 as INPUT

  pinMode(3, OUTPUT); //PIN 3 as OUTPUT

}

Arduino

Arduino
void setup() {

  pinMode(2, INPUT); //Pin 2 as INPUT

  pinMode(3, OUTPUT); //PIN 3 as OUTPUT

}


void loop() {

  if (digitalRead(2) == HIGH) // check if PIR is triggered.

  {

  digitalWrite(3, HIGH);   // turn the LED/Buzz ON

  delay(100);                       // wait for 100 msecond

  digitalWrite(3, LOW);   // turn the LED/Buzz OFF

  delay(100);                       // wait for 100 msecond

  }

}

Credits

Lisleapex Blog
28 projects • 0 followers
Fast Delivery of High-Quality Electronic Components

Comments