Skip to content

Reading Analog Sensors - the Pico ADC

Beginning of the lesson

Reading Analog Sensors — the Pico ADC

So far every input on your Pico has been digital: a button is either pressed or not, a pin reads either 0 or 1. But the real world is not made of on/off switches. A dimmer knob can be at 0%, 37%, or 82%. A room can be pitch dark, dim, bright, or dazzling. Temperature slides smoothly from cold to hot. These are analog quantities — they can take any value in a range, not just two.

A microcontroller, though, can only ever store numbers. So we need a translator that turns a smoothly-varying voltage into a plain number the program can work with. That translator is called an ADC — an Analog-to-Digital Converter. Your Pico has one built in. In this lesson you will read a knob (potentiometer), read a light sensor (photoresistor), convert the raw number into a real voltage, smooth out jumpy readings, and build a knob-controlled LED dimmer.

What you will learn
  • What "analog" means and why a plain digital pin cannot measure it.
  • What an ADC does: it turns a voltage into a number.
  • Which Pico pins are analog inputs (GP26, GP27, GP28 — called ADC0, ADC1, ADC2).
  • How to read a value with machine.ADC and read_u16(), and what the range 0–65535 means.
  • How to convert the raw number into a real voltage with actual worked numbers.
  • How to wire a potentiometer as a voltage divider and read a knob's position.
  • How to map that reading to LED brightness — a full pot dimmer project.
  • How to sense light with a photoresistor, and how to calibrate a threshold.
  • How to average many readings to kill "jumpy" noise.
  • How to fix the two most common ADC mistakes.

1. Analog vs. digital: the big idea

A digital signal has only two states. Think of a normal light switch: it is UP or DOWN, on or off. On the Pico a digital input pin reads only 0 or 1. That was perfect for a button.

Continue this lesson on YourAIZone

The full lesson has the complete explanation, worked examples, common mistakes, tests with instant checking and an AI tutor. Start right away as a guest, or create an account to keep your progress.

In the full lesson

  • The complete explanation
  • Worked examples
  • Common mistakes and how to avoid them
  • Test questions: 15
  • AI tutor that answers questions about the topic
  • Progress tracking for students, parents and teachers