Read a sensor voltage (ADC)
Read an analog pin and print the voltage. Open Tools > Plotter to see it as a chart.
A starter program from the MantisIDE Full IDE (Tools › Examples). Press Open in Full IDE to run it on your board, change it, and save it as your own.
# Read an analog pin and print the voltage. Open Tools > Plotter to see it as a chart.
from machine import ADC, Pin
import time
adc = ADC(Pin(34)) # Pico: ADC(26)
while True:
raw = adc.read_u16()
print("volts:", round(raw * 3.3 / 65535, 3))
time.sleep(0.2)
Comments