void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
for(int i=6;i<=8;i++)
pinMode(i, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int pir=digitalRead(8);
if(pir==HIGH){
Serial.print("MOTION DETECTED\n");
tone(6,500);
digitalWrite(7,LOW);
}
else{
Serial.print("MOTION NOT DETECTED\n");
noTone(6);
digitalWrite(7, HIGH);
}
delay(2000);
}