from machine import Pin, PWM
import time,random,tm1637
rLED = PWM(Pin(12)) # 控制紅燈
gLED = PWM(Pin(13)) # 控制綠燈
bLED = PWM(Pin(14)) # 控制藍燈
tm = tm1637.TM1637(clk=Pin(22), dio=Pin(23))
def red_light():
rLED.duty(225)
gLED.duty(0)
bLED.duty(0)
def green_light():
rLED.duty(0)
gLED.duty(225)
bLED.duty(0)
red_sec = eval(input('RED light seconds:'))
green_sec = eval(input('GREEN light seconds:'))
while 1:
red_light()
time.sleep(red_sec)
green_light()
time.sleep(green_sec)