import machine
import time from machine
led1 = machine.Pin(15, machine.Pin.OUT)
led2 = machine.Pin(2, machine.Pin.OUT)
led3 = machine.Pin(13, machine.Pin.OUT)
led4 = machine.Pin(4, machine.Pin.OUT)
led5 = machine.Pin(5, machine.Pin.OUT)
adc = machine.ADC(0) # create ADC object on ADC pin
def led_off():
led1.off()
led2.off()
led3.off()
led4.off()
led5.off()
while True:
a=adc.read()
a=a*5.0/1024
print(a)
led_off()
if 0<a<=1:
led1.on()
if 1<a<=2 :
led2.on()
if 2< a<=3 :
led3.on()
if 3<a<=4 :
led4.on()
if 4<a<=5 :
led5.on()
time.sleep(0.1)
# read value, 0-1024