This is a basic level lazer alarm project. When anyone crosed or kept their hands on the lazer. buzzer starts working but when they took their hand from lazer light buzzer stops. But i want even after taking hands my buzzer should work for few (15-30) seconds .so please help me by giving idea..
If you are using a digital buzzer, you can do:
digitalWrite(buzzerPin,HIGH);
delay(1000);
digitalWrite(buzzerPin,LOW);
BlinkWithoutDelay
example and learn how to use themillis()
function (There are also many tutorials on the web for it). Then start the buzzer, when the lazer barrier triggers, set a timestamp there. When the difference between the currentmillis()
value and the timestamp is over your 15-30s, turn of the buzzer – chrisl Jun 18 '20 at 9:06[turn on buzzer]; delay(15000); [turn off buzzer];
– Gerben Jun 18 '20 at 16:05