stoplicht zonder zoemer

from gpiozero import Button, TrafficLights

knop= Button(21)

lights= TrafficLights(25, 8, 7)

 

while True:

      Button.wait_for_press()

      lights.on()

      Button.wait_for_release()

      lights.off() 

 

stoplicht met zoemer

from gpiozero import Button, TrafficLights, Buzzer

knop= Button(21)

lights= TrafficLights(25, 8, 7)

zoemer= Buzzer(15)

 

while True:

      lights.on(0)

      zoemer.off()

      knop.wait_for_press()

      lights.off()

      zoemer.on()

      knop.wait_for_release()