from machine import Pin
import time, random
ledRed = Pin(27, Pin.OUT)
ledGreen = Pin(28, Pin.OUT)
ledYellow = Pin(26, Pin.OUT)
ledBlue = Pin(22, Pin.OUT)
switch = Pin(2,Pin.IN,Pin.PULL_UP)
button = Pin(3,Pin.IN,Pin.PULL_UP)

def turn_leds(randomvalue):
    ledRed.off()
    ledGreen.off()
    ledYellow.off()
    ledBlue.off()
    print(randomvalue)

    if randomvalue==1:
        ledRed.on()
    if randomvalue==2:
        ledGreen.on()
    if randomvalue==3:
        ledYellow.on()
    if randomvalue==4:
        ledBlue.on()

while True:
    i=0
    while(switch.value()):
        if button.value():
            i = i+1
        else:
            i= i-1
        if i>4:
            i = 0
        if i<0:
            i=4
        turn_leds(i)
        time.sleep(0.25)
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT