from mechine import Pin, ADC, Timer
Led_1 = Pin(32, Pin.OUT)
Led_2 = Pin(26, Pin.OUT)
button = Pin(35, Pin.IN_PULLUP)
adc = ADC(Pin(34))
adc.atten(ADC.ATTN_6DB) # ATENUATION(150mV-1750mV) voltage rang for the program
adc.width(ADC.WIDTH_9BIT)# WIDTH SET UP THE NUMBER OF VALUES AN ADC CAN RUN IN THE CODE
while True:
adc_value = read.adc_value()
volts = (3.3*adc_value)/511
string = "(The voltage is {:0.2f} form {:4d})"
print(string.format(volts, adc_value, end = "\r")
def handler_0(tim0):
Led_1.value(not Led_1.value())
tim0 = Timer(0)
tim0.unit(period=500, mode=Timer.ONE_SHOT, callback=handler_0)