import machine
print(machine.freq()/(1e6))
import random
from machine import Pin, Timer
import time


# for i in range(20):
#     led.off()
#     time.sleep(0.3)
#     led.on()
#     time.sleep(0.3)
# led.off()

# for i in range(20):
#     led.toggle()
#     time.sleep(0.3)


# red_led.on()
# time.sleep(10)
# red_led.off()

# green_led.on()
# time.sleep(10)
# green_led.off()

# timer = Timer()

# def blink_led(timer):
#     yellow_led.on()
#     time.sleep(0.5)
#     yellow_led.off()
#     time.sleep(0.5)

# timer.init(freq=2,mode=Timer.PERIODIC,callback=blink_led)
# time.sleep(5)
# yellow_led.off()
# timer.deinit()
red_led = Pin(1,Pin.OUT)
yellow_led = Pin(5,Pin.OUT)
green_led = Pin(9,Pin.OUT)

def traffic_signal():
    x=random.random()
    if x>0.75:
        red_led.on()
        time.sleep(1)
        red_led.off()
    elif x>0.5:
        yellow_led.on()
        time.sleep(1)
        yellow_led.off()
    else:
        green_led.on()
        time.sleep(1)
        green_led.off()

while 1:
    traffic_signal()
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT