from machine import Pin
import time
# Define LEDs and button
leds = [Pin(i, Pin.OUT) for i in [1, 2, 3, 28, 27]]
button = Pin(21, Pin.IN)
current_led = 0
def light_up(index):
# Turn on only the LED at the specified index, turn off others
for i, led in enumerate(leds):
led.value(i == index)
while True:
if button.value() == 1: # Button pressed
current_led = (current_led + 1) % len(leds)
light_up(current_led)
time.sleep(0.75)
'''def lightup(on):
for i in range(5):
if i==on:
led[i].value(1)
else:
led[i].value(0)
while True:
if pbutton.value() == 1:
if current_led==-1:
current_led=0
else:
current_led = (current_led + 1) % 5
lightup(current_led)
time.sleep(0.75)'''