from time import sleep
from machine import ADC
#Define pins
button_1 = Pin(16, Pin.IN, Pin.PULL_UP)
thermistor_adc = ADC(26)
button_state = 0
def is_button_pressed(pin):
global button_state
button_state = button_state << 1 | pin.value()
button_state = button_state & 0xFFFF
return button_state == 0x8000
while True:
if is_button_pressed(button_1):
while True:
# Read ADC digital output
digital_val = thermistor_adc.read_u16()
# Calculate analog value
analog_val = float((digital_val/(2**16-1)) * 3.3)
print(analog_val)
sleep(.05)