The traffic light created here aims to achieve energy efficiency both during the day and at night, reducing traffic congestion, and being environmentally friendly.
import time
def traffic_light_mode(hour): # Day mode: 06:00 - 22:00 a.m # Night mode: 22:00 - 06:00 p.m if 6 <= hour < 22: return "Day" else: return "Night"
def traffic_light_mode(hour): if mod == "Day": print("GREEN light 5 seconds") time.sleep(5) # wait 5 seconds print("YELLOW light 2 seconds") time.sleep(2) # wait 2 seconds print("RED light 5 seconds") time.sleep(5) # wait 5 seconds else: # night mode print("YELLOW light flashing, 2 seconds") time.sleep(2) # wait 2 seconds
hour = int(input("Please enter current time (0-23): "))
mod = traffic_light_mode(hour):
traffic_heat_control(mode)
// We can transform this control system, which can also be done with PLC programming, into a more understandable system using the Phyton software language.//