analogRead · PWM

ADC Voltage & PWM Duty Cycle Calculator

Quickly translate analogRead() sensor counts into real volts and convert target PWM percentages into exact analogWrite() or ESP32 ledcWrite() register values.

Target Microcontroller

ADC Reading Converter (analogRead)

Raw ADC Value (0..1023)512
Full-Scale %50.0% (2.502 V)

PWM Duty Cycle Converter (analogWrite / ledcWrite)

Duty Cycle (%)50.0%
Equivalent Avg Voltage2.51 V / 5.0 V
Generated Arduino / ESP32 Code Snippet
// Arduino Uno / Nano (5.0V, 10-bit ADC, 8-bit PWM)
int raw = analogRead(A0); // 512 -> 2.50V (50.0%)
float volts = raw * (5.0f / 1023.0f);
analogWrite(9, 128); // 50.0% duty (~2.51V avg)

Frequently Asked Questions

How do I convert Arduino Uno analogRead() to voltage in C++?

Multiply raw reading (0-1023) by 5.0 and divide by 1023.0: float volts = analogRead(A0) * (5.0 / 1023.0);

Why does ESP32 analogRead() go up to 4095 instead of 1023?

Arduino Uno has a 10-bit ADC (2^10 = 1024 steps: 0-1023), while ESP32 has a 12-bit ADC (2^12 = 4096 steps: 0-4095) across 0-3.3V.

Explore all hardware & embedded dev tools

Compare IDEs

Chrome USB WebSerial + 300 Free Credits

Test Your Circuit & Flash Real Hardware Free in Chrome

Open Gokino in Chrome, let AI generate interactive /wiring circuit diagrams, fix C++ bugs in 1 click, and upload directly to Arduino, ESP32, or STM32 with zero installation.

Launch Gokino IDE Free