import time
from machine import Pin, ADC
#定义ADC对象
adc = ADC(Pin(36)) #pin36即是espe32 的svp脚,具体可以看ESP32引脚图
#配置衰减器
adc.atten(ADC.ATTN_11DB)
voltage=0
val_old=adc.read()
while True:
# val_new = adc.read()
# if val_old != val_new:
# val_old = val_new
voltage=adc.read() *4.8/4096
# print(f'adc:{adc.read()}')
print(f'{voltage}')
# print(voltage)
time.sleep(1)