from machine import ADC, Pin import time REFERENCE_VOLTAGE = 3.3 # Setup ADC for pin 26 (A0 on the XIAO RP2040) adc = ADC(Pin(26)) def read_voltage(adc): value = adc.read_u16() # Read the raw 16-bit value voltage = (value / 65535) * REFERENCE_VOLTAGE # Convert to voltage return voltage while True: voltage = read_voltage(adc) print("Voltage:", voltage, "V") time.sleep(1) # Wait for a second before reading again