from machine import Pin, ADC, Timer
adc = ADC(Pin(2))
adc.atten(ADC.ATTN_11DB)
adc.width(ADC.WIDTH_10BIT)
led_35 = Pin(35, Pin.OUT)
led_32 = Pin(32, Pin.OUT)
led_33 = Pin(33, Pin.OUT)
led_25 = Pin(25, Pin.OUT)
led_26 = Pin(26, Pin.OUT)
switch = 0
def handler_0(tim0):
led_35.value(not led_35.value())
led_32.value(not led_32.value())
led_33.value(not led_33.value())
led_25.value(not led_25.value())
led_26.value(not led_26.value())
global switch
r = dict(zip(range(601),["'Low'"]*40+["'Medium"]*80+["'Avergae"]*80+["'High"]*300+["'Max"]*100+["'Super_max"]))
while True:
val = adc.read()
switch = 0
if val >= 600:
val = 600
input_voltage = "The raw is analogue {} and the condition is {}"
print(input_voltage.format(val,r[val]), end = "\r")
tim0 = Timer(0)
tim0.init(period = 1500, mode = Timer.PERIODIC, callback = handler_0)