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)
button2=Pin(2,Pin.IN,Pin.PULL_UP)
button3=Pin(3,Pin.IN,Pin.PULL_UP)
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()
#main loop
while True:
i=0
while(button2.value()):
if button3.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)