Learning Arduino for beginners EP#31 PIR sensors

In this episode we will take a look at how to use PIR infrared sensors with your Arduino…

Click on video below for full tutorial:

Check us out on Facebook!

Parts list:

affiliate links

ARDUINO board

PIR sensor

ARDUINO Code:

#define led 13
int state = 1;
void setup() {
pinMode(led, OUTPUT);
attachInterrupt(0, PIR, RISING); //pin 2

}

void loop() {
// put your main code here, to run repeatedly:

}
void PIR() {
if (state == 1)
{
digitalWrite(led, HIGH);
state = 2;
}
else if (state == 2)
{
digitalWrite(led, LOW);
state = 1;
}

}