Hey guys, i bumped in to the one problem where i cant really make buzzer sound from 2 PIR sensors, i mean only one makes buzzer to buzz, second does nothing
int buzzer = 13; // choose the pin for the LED
int inputPin = 2;
int inputPin1 = 3; // choose the input pin (for PIR sensor)
int pirState = HIGH; // we start, assuming no motion detected
int val = 0;
int val1 = 0; // variable for reading the pin status
void setup() {
pinMode(buzzer, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT);
pinMode(inputPin1, INPUT); // declare sensor as input
Serial.begin(9600);
}
void loop(){
val = digitalRead(inputPin);
val1 = digitalRead(inputPin1);// read input value
if ( (val1 == LOW) or (val == LOW) ) { // check if the input is HIGH
digitalWrite(buzzer, HIGH); // turn LED ON
if (pirState == LOW) {
// we have just turned on
Serial.println("Motion detected!");
// We only want to print on the output change, not state
pirState = HIGH;
}
} else {
digitalWrite(buzzer, LOW); // turn LED OFF
if (pirState == HIGH){
// we have just turned of
Serial.println("Motion ended!");
// We only want to print on the output change, not state
pirState = LOW;
}
}
}
here's the code im using