import time
import machine
import random
from machine import Pin, Timer

#pin 25 connected directly to the led
#creating a cnstructor
ledr = Pin(1, Pin.OUT)
ledy = Pin(5, Pin.OUT)
ledg = Pin(9, Pin.OUT)

# print(machine.freq())

def blink_ledr(timer):
    ledr.on()
    time.sleep(0.5)
    ledr.off()
    time.sleep(0.5)

def blink_ledy(timer):
    ledy.on()
    time.sleep(0.5)
    ledy.off()
    time.sleep(0.5)

def blink_ledg(timer):
    ledg.on()
    time.sleep(0.5)
    ledg.off()
    time.sleep(0.5)

while(1):
    r=random.uniform(0,1)
    print(r)
    timer = Timer()
    if r<0.5:
        timer.init(freq=2, mode=Timer.PERIODIC, callback=blink_ledr)
    elif 0.5<r<0.75:
        timer.init(freq=2, mode=Timer.PERIODIC, callback=blink_ledy)
    else:
        timer.init(freq=2, mode=Timer.PERIODIC, callback=blink_ledg)

time.sleep(0.1)
timer.deinit()
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT