this is my first raspberry pi project and it’s for university. I have a led, a button a buzzer and a servo motor connected, they all work perfectly fine. The idea is, when the servo motor is moved, the LED goes on and if the LED is on for more than 5 seconds the buzzer needs to go off. For some reason, I can’t delay the sound, is there a way to delay the sound of the buzzer for 5 seconds? Any help or guidance is appreciated!
This is the code I used:
buzzer = Buzzer(18)
servo = Servo(17)
button = Button(2)
led = Led(27)
While True:
button.wait_for_press()
led.on()
servo.max()
buzzer.on(on_time_0.5,off_time:5,n=None,background=True)
sleep(0.5)
button.wait_for_press()
buzzer.off()
led.off()
servo.min()
sleep(0.5)