from machine import Pin
from time import sleep
# Define button pins
button_1 = Pin(16, Pin.IN) # Button to turn LEDs on
button_2 = Pin(17, Pin.IN) # Button to turn LEDs off
# Keep track of which LED to turn on or off next
count = 1 # Start with the first LED (pin 10)
while True:
if button_1.value() == 1:
if count <= 10:
pin_number = 11 - count
led = Pin(pin_number, Pin.OUT)
led.value(1) # Turn on the LED
count += 1 # Move to the next LED
sleep(0.3) # Debounce delay
if button_2.value() == 1:
if count > 1:
count -= 1 # Decrement count to go back one LED
pin_number = 11 - count
led = Pin(pin_number, Pin.OUT)
led.value(0) # Turn off the corresponding LED
sleep(0.3) # Debounce delay