Foundations · Lesson 7 of 11 · about 10 min

ADC: reading the analog world

From a voltage to a number

Temperature, light and pressure change smoothly, but the CPU only understands numbers. The analog-to-digital converter (ADC) takes snapshots of a voltage and rounds each one to the nearest step.

uint16_t raw = HAL_ADC_GetValue(&hadc1);   // 0 .. 4095
float volts = raw * 3.3f / 4095;           // 2048 -> 1.65 V
// volts -> temperature, light, pressure: the formula is in the sensor's datasheet

Interview questions

  1. What limits the accuracy of an ADC reading?
  2. What happens if you sample a signal too slowly?
  3. How do you turn a raw 12-bit reading into volts?

No answers here on purpose: try answering out loud first. In the BoardPilot app, the interview coach reads your own answer and tells you what was right, what is missing and what a senior interviewer would ask next (it uses the AI provider you choose in the app). Embedded systems interview questions →

Key terms

In the app, the lessons come alive

The lessons have interactive demos and hands-on labs checked on your board in the app. These pages are the readable version: the demos are described in words, and the labs need the app.

Download BoardPilot Try the lessons in your browser