I've just connected my sr501 pir sensor to my arduino with a buzzer turning on when the motion detector is high.
the sr501 minimal time delay is 3-5 sec but its really long when you listen to this buzzer.
I tried to change it with code but I probably miss something because its not working.
I tried to chgnde to buzzed to low but I guess itn stop the electricity but dont stop it.
is there a way to change it?
this is the code(not mine):
//define the pins
int LED = 4;
int PIR = 7;
int Buzzer = 2;
void setup() {
//define the LED and Buzzer pin as output
pinMode(LED, OUTPUT);
pinMode(Buzzer, OUTPUT);
//define the sensor pin as input
pinMode(PIR, INPUT);
}
void loop() {
//using the digitalRead function we will read the signal of the sensor
int value = digitalRead(PIR);
//if its high or if an any object is detected it will activate the LED and Buzzer
if (value == HIGH){
digitalWrite(LED, HIGH);
digitalWrite(Buzzer, HIGH);
delay (300);
digitalWrite(Buzzer, LOW);
}
else {
digitalWrite(LED, LOW);
digitalWrite(Buzzer, LOW);
}
}
Show how you have connected the PIR and Buzzer to the Arduino.
In your loop, if the PIR detects any movement, it turns on the buzzer. so if it's on your desktop right in front of you, it will never stop buzzing. Put a paper cup over the PIR. Does it stop now?