Analog to Digital Conversion
A microcontroller cannot read a voltage directly. Its analog to digital converter, or ADC, compares the voltage against a reference and outputs a whole number. More bits mean finer steps.
Steps and codes
An \(N\)-bit ADC with reference voltage \(V_{\text{ref}}\) splits the range into \(2^N\) steps. One step is called an LSB, the least significant bit:
What to notice
At 1 or 2 bits, the red staircase barely resembles the signal. Each added bit halves the step size, and the quantization error in the lower plot shrinks to stay within half a step. Common microcontrollers have 10 or 12 bit ADCs, so a 3.3 V reference gives steps of about 3.2 mV or 0.8 mV.
Raise the signal size past the reference and the tops get clipped flat, since the ADC cannot report anything above its highest code. Lowering the reference gives finer steps but clips sooner. Matching the reference to the sensor's range gets the most out of the bits.