from machine import Pin _init() ledPins = [5,12,13,14,15,16] leds = [] for pinNum in ledPins: leds.append(Pin(pinNum, Pin.OUT)) adc = machine.ADC(0) def ledOff(): for led in leds: led.off() def ledOn(count): for i in range(count): led = leds[i] led.on() while True: value = adc.read() ledOff() if value in range(0,170): ledOn(1) elif value in range(171,340): ledOn(2) elif value in range(341,510): ledOn(3) elif value in range(511,680): ledOn(4) elif value in range(681,850): ledOn(5) elif value in range(851,1023): ledOn(6)