You are on page 1of 1

int pirPin = 2;

int val;
int ledred = 7;
int ledyellow = 8;
void setup()
{
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
Serial.begin(9600);
}
void loop()
{
val = digitalRead(pirPin); //read state of the PIR

if (val == LOW)
{
Serial.println("No motion"); //if the value read is low, there was no motion
digitalWrite(7, LOW);
}
else
{
Serial.println("Motion!"); //if the value read was high, there was motion
digitalWrite(7, HIGH);
delay(500);
digitalWrite(7, LOW);
delay(200);
digitalWrite(8, HIGH);
delay(100);
digitalWrite(8, LOW);
delay(500);
}

delay(800);
}

You might also like