from machine import Pin, ADC
from time import sleep
boton = Pin(11, Pin.IN, Pin.PULL_UP)
pot = ADC(26)
ledv = (13, Pin.OUT)
leda = (14, Pin.OUT)
ledr = (12, Pin.OUT)
sistema_activo = False
estado_anterior_boton = 1
while True:
lectura_boton = boton.value()
if lectura_boton == 0 and estado_anterior_boton == 1:
sleep(0.05)
if boton.value() == 0
sistema_activo = not sistema_activo
estado_anterior_boton = lectura_boton
if sistema_activo:
valor = pot.read_u16()
porcentaje = int((valor /65535) * 100)
if porcentaje <= 33:
ledv.value(1)
leda.value(0)
ledr.value(0)
print("SISTEMA ACTIVO | RANGO BAJO |" , porcentaje, "%")
elif porcentaje <= 66:
ledv.value(0)
leda.value(1)
ledr.value(0)
print("SISTEMA ACTIVO | RANGO MEDIO |" , porcentaje, "%")
else:
ledv.value(0)
leda.value(0)
ledr.value(1)
print("SISTEMA ACTIVO | RANGO ALTO |" , porcentaje, "%")
else:
ledv.value(0)
leda.value(0)
ledr.value(0)
print("SISTEMA DESACTIVADO")