An ADC (Analog-to-Digital Converter) is the peripheral that turns an analog voltage into a number the program can work with, for instance the voltage a temperature sensor or a potentiometer delivers. Its resolution, in bits, sets how fine the measurement is: the higher it goes, the more voltage steps can be told apart.

Quantisation: a continuous analog signal (grey curve) is rounded by the ADC to the nearest step (amber staircase); one step is worth the reference voltage divided by 2 to the power n.

What is it for?

Without an ADC, a microcontroller senses nothing but on or off on its logic pins. The ADC is what gives it access to the continuous quantities of the real world. Every analog sensor reading goes through it.

In practice

The conversion refers the voltage read to the reference voltage (full scale, often the supply: 5 V on an Uno, 3.3 V on an ESP32) and cuts it into 2ⁿ steps: 10 bits gives 1024 values (one step ≈ 5 mV on 5 V), 12 bits gives 4096. Two pitfalls here. Going past full scale: beyond the reference the reading saturates, and a 5 V sensor wired to a 3.3 V ADC threatens the pin itself (→ concept page Logic levels). Confusing resolution with accuracy: more steps does not mean a truer measurement. The ESP32’s 12-bit ADC, notoriously non-linear, is the illustration (→ concept page Accuracy, trueness, precision). Reading one in practice: Reading an analog sensor for Arduino, Reading an analog sensor for MicroPython.

See also