Friday, 3 February 2023

TRL - Exercise2c

#Using def function #Library from gpiozero import LED from time import sleep #Setup Components / Variables tf_red_led = LED(13) tf_amber_led = LED(19) tf_green_led = LED(26) #Alorgithm #Initialize the LEDs tf_red_led.off() tf_amber_led.off() tf_green_led.off() def trafficLight(): tf_green_led.on() sleep(10) tf_green_led.off() tf_amber_led.on() sleep(5) tf_amber_led.off() tf_red_led.on() sleep(10) tf_red_led.off() while True: trafficLight()

No comments: