- R1 – 7.5K
R2 – 30K
from machine import ADC
from time import sleep
# Use ADC0 (GPIO26)
adc = ADC(26)
# Constants
VREF = 3.3 # Pico ADC reference voltage
ADC_RESOLUTION = 65535 # For read_u16() scale
DIVIDER_RATIO = 5 # Because 7.5k / (30k + 7.5k) = 0.2 → inverse is 5
def read_input_voltage():
raw = adc.read_u16()
v_out = (raw / ADC_RESOLUTION) * VREF
v_in = v_out * DIVIDER_RATIO
return round(v_in, 3)
# Main loop
while True:
voltage = read_input_voltage()
print("Measured Voltage:", voltage, "V")
sleep(1)
Since the Pico ADC max is 3.3V and you’re dividing by 5: Vin max=3.3V×5=16.5VV = 3.3V \times 5 = 16.5V
Vin max=3.3V×5=16.5V
So you can safely measure up to about 16.5 volts.