from machine import Pin, PWM
import time, random
ledRed = Pin(27, Pin.OUT)
ledGreen = Pin(28, Pin.OUT)
ledYellow = Pin(26, Pin.OUT)
ledBlue = Pin(22, Pin.OUT)

def turn_leds(randomvalue):
    #turn off all leds
    ledRed.off()
    ledGreen.off()
    ledYellow.off()
    ledBlue.off()
    print(randomvalue)
    #turn on the proper led
    if randomvalue==1:
        ledRed.on()
    if randomvalue==2:
        ledGreen.on()
    if randomvalue==3:
        ledYellow.on()
    if randomvalue==4:
        ledBlue.on()

d = 0

while d != 20:
    #Generate a random number between 1 and 4
    d = d+1
    color = random.randint(1,4)
    turn_leds(color)
    time.sleep(1)
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT