import time
from machine import Pin, PWM
import utime, math
pwm=PWM(Pin(2),freq=50,duty=0)
def servo(seryo,angle):
pwm.duty(int(((angle)/180*2+0.5)/20*1023))
LED1=Pin(19,Pin.OUT)
LED2=Pin(21,Pin.OUT)
LED3=Pin(22,Pin.OUT)
def rlight(sec):
LED1.value(1)
LED2.value(0)
LED3.value(0)
servo(2,0)
time.sleep(sec)
def ylight(sec):
LED1.value(0)
LED2.value(1)
LED3.value(0)
time.sleep(sec)
def glight(sec):
LED1.value(0)
LED2.value(0)
LED3.value(1)
Servo(2,90)
time.sleep(sec)
rtime=int(input("input red light lasts seconds:"))
gtime=int(input("input red light lasts seconds:"))
while 1:
rlight(rtime)
glight(gtime-2)
ylight(2)