from machine import Pin
from time import sleep
led_pins = [Pin(5, Pin.OUT), Pin(18, Pin.OUT), Pin(19, Pin.OUT)]
btn_pins = [Pin(25, Pin.IN, Pin.PULL_UP), Pin(14, Pin.IN, Pin.PULL_UP), Pin(13, Pin.IN, Pin.PULL_UP)]
while True:
pressed_count = 0
for btn in btn_pins :
pressed_count += not btn.value()
# Turn LEDs on according to pressed_count
for i, led in enumerate(led_pins):
if i < pressed_count :
led.value(1)
else :
led.value(0)
sleep(0.1) # small delay to reduce CPU usage