from machine import Pin,ADC
from utime import sleep_ms
Led1=Pin(23, Pin.OUT)
Led2=Pin(22, Pin.OUT)
while True:
pot=ADC(32) #nombrar pin del potenciometro
analog=pot.read() #variable de lectura .read()
#print(analog)
volt=(3.3*analog)/4095 #converciones a voltaje
print(volt)
#volt=pot.read()
sleep_ms(500)
if volt < 0.4:
Led1.off()
Led2.off()
sleep_ms(500)
print("el voltaje es bajo")
elif volt >= 0.5 and volt <= 1.8:
Led1.off()
Led2.on()
sleep_ms(500)
print("el voltaje es medio bajo")
elif volt >= 1.9 and volt <= 2.4:
Led1.on()
Led2.off()
sleep_ms(500)
print("el voltaje es medio alto")
else:
Led1.on()
Led2.on()
sleep_ms(500)
print("el voltaje es alto")