Analog-to-Digital Conversion
How a microcontroller, which only understands HIGH and LOW, manages to measure a smoothly-varying analog voltage like a temperature sensor's output.
A microcontroller's GPIO pins are fundamentally digital — they read a voltage as either HIGH or LOW, nothing in between. But plenty of real-world signals are analog: a temperature sensor's output might smoothly vary anywhere between 0V and 3.3V depending on the temperature. To bridge that gap, microcontrollers include an analog-to-digital converter (ADC), a peripheral that measures an analog voltage and reports it back as a number your program can use.
An ADC's precision is described by its resolution, measured in bits. A 10-bit ADC (common on many microcontrollers) divides its full voltage range into 2^10 = 1024 discrete steps, so it can report the input voltage as any whole number from 0 to 1023. Reading 0 means "voltage is at the bottom of the range"; reading 1023 means "voltage is at the top." Higher resolution (12-bit, 16-bit) gives finer, more precise steps, at the cost of a slightly slower conversion and more complex hardware.
This step-by-step rounding is called quantization — the ADC can't represent every possible voltage exactly, only the nearest one of its available steps. For most sensor work this rounding error is small enough to ignore; for high-precision audio or measurement work, it becomes something engineers carefully account for.
Reading an ADC in code is usually a single function call (on an Arduino, analogRead(pin)) that returns the current numeric reading — your program then converts that raw number into a meaningful unit, like degrees or volts, using the sensor's known behavior.