/* * PIR sensor tester */ int LED = 13; // LED's and buzzeer pin int PIR = 7; // Output of PIR sensor pin int PIRState = LOW; // initial status of PIR sensor int VAL = 0; // set VAL as an integer variable void setup() { pinMode(LED, OUTPUT); // LED pin as output pinMode(PIR, INPUT); // PIR sensor output pin as input Serial.begin(9600); // open seria; monitor } void loop(){ VAL = digitalRead(PIR); if (VAL == HIGH) { // if the sensor's input is HIGH digitalWrite(LED, HIGH); // turn LED and Buzzer ON if (PIRState == LOW) { Serial.println("There is a Motion !"); // only print on the output change, not state PIRState = HIGH; //Change the state } } else { digitalWrite(LED, LOW); // turn LED OFF if (PIRState == HIGH){ Serial.println("Motion stopped !"); // only print on the output change, not state PIRState = LOW;//Change the state again } } }