In embedded systems, microcontrollers cannot understand continuous analog signals. To process data from sensors like temperature probes, microphones, or potentiometers, we use an Analog-to-Digital Converter (ADC). The ADC samples the analog voltage and assigns it a discrete digital number.
The Conversion Mathematics
The accuracy of this conversion depends on two main factors: the Reference Voltage ($V_{ref}$) and the Resolution in bits ($N$). A standard STM32 microcontroller, for example, typically uses a 12-bit ADC, giving it $2^{12} = 4096$ possible steps (from 0 to 4095). The formula to convert an input voltage ($V_{in}$) into a digital ADC value is:
The smallest change in voltage the ADC can detect is called the LSB (Least Significant Bit) size or step size. I designed the interactive tool below to instantly calculate your LSB, convert voltages to digital values (in Decimal and Hex), and translate raw ADC readings back into voltages.
``