Video summary

micropython analog inputs

Main summary

Key takeaways

Technology

MicroPython analog inputs (Raspberry Pi Pico)

Key concepts

  • Analog vs digital
    • Analog: continuous measurements (infinite values between two points).
    • Digital: discrete states (e.g., on/off). Microcontrollers read GPIO pins as high/low using a threshold.
  • ADC (Analog-to-Digital Converter)
    • Maps an analog voltage to a discrete integer value across N steps (resolution).
    • Resolution = 2^bits. Example: 8-bit → 256 steps; 16-bit → 65,536 steps (values 0..65,535).
    • ADC values range from 0 to (2^bits − 1). The voltage step size is Vref / (2^bits − 1); for a 16-bit ADC over 0–3.3 V this is 3.3 / 65,535.

Raspberry Pi Pico specifics

  • The Pico has five ADC channels internally; three are exposed for external inputs:
    • ADC0 → GP26
    • ADC1 → GP27
    • ADC2 → GP28
  • The remaining ADC channels are used for internal measurements (on‑chip temperature sensor and input/board voltage).
  • Pico ADC range: 0–3.3 V. MicroPython returns 16-bit readings (integer values 0..65,535).

Hardware example: potentiometer

  • Wiring
    • One outer pin of the potentiometer → 3.3 V
    • Other outer pin → GND
    • Middle/wiper pin → ADC input (e.g., GP26)
  • Behavior
    • The potentiometer acts as a variable voltage divider. Turning the dial changes the voltage at the wiper, which the ADC reads.

MicroPython usage (quick guide)

  • Typical imports:
from machine import Pin, ADC
import utime  # or: import time
  • Create an ADC instance for GP26:
adc = ADC(26)   # ADC0 / GP26
  • Read a raw ADC value (returns 0..65535):
value = adc.read_u16()
  • Example: continuously print raw ADC value and computed voltage, and toggle an LED on Pin 0 based on the reading:
from machine import Pin, ADC
import utime

adc = ADC(26)            # GP26 / ADC0
led = Pin(0, Pin.OUT)

while True:
    raw = adc.read_u16()                  # 0..65535
    volts = raw * 3.3 / 65535             # convert to volts
    print(raw, "{:.3f} V".format(volts))
    if raw > 35000:
        led.on()
    else:
        led.off()
    utime.sleep_ms(200)
  • Note: regular digital GPIO reads use a voltage threshold to decide high vs low; ADC provides a precise measurement across the whole range.

Practical tips / gotchas

  • Double-check wiring: ensure the wiper is connected to the correct GP pin (GP26/GP27/GP28). Wrong pin → no or incorrect readings.
  • Be aware of the small ambiguous threshold region around digital high/low switching when using GPIO as digital inputs.
  • Watch for syntax/casing errors in code (class and variable names are case-sensitive in MicroPython).
  • Remember the Pico ADC measures 0–3.3 V — don’t exceed that range without proper scaling/protection.

Source: hands-on MicroPython tutorial/demonstration (unnamed instructor) showing ADC use on the Raspberry Pi Pico.

Rate this summary

Your feedback will help improve summaries.

Improve this summary

Reprocess with a stronger model when the summary feels incomplete or inaccurate.

Pro

Translate summary in another language

Pro

Ask questions to this video

Chat for follow-up questions, clarifications, and source-backed answers.

Coming soon

Share this summary

Original video