from machine import ADC, Pin
import time
adc = ADC(Pin(35))
adc.atten(ADC.ATTN_11DB)
adc.width(ADC.WIDTH_12BIT)
def leer_promedio(n=20):
suma = 0
for _ in range(n):
suma += adc.read()
time.sleep(0.01)
return suma / n
while True:
valor_prom = leer_promedio()
voltaje = (valor_prom / 4095) * 3.3
print("Valor ADC promedio:", int(valor_prom), "| Voltaje aproximado:", round(voltaje, 2), "V")
time.sleep(1)