1. Electronics Tools
  2. Number Converter

Number Converter

Turn an ADC reading into volts (and back) for your board, with an input divider, or convert hex, binary, decimal and octal and flip bits one by one.

001010000x28 = 402.5 V
Board

ADCArduino Uno · ATmega328P

V

1,024 steps · 1 LSB = 4.883 mV · full scale 5 V

Input divider

/ 1023

Transfer curve and staircase

0 V01.25 V2562.5 V5123.75 V7675 V1023pin voltagecode2.5 V512Zoom: 1 tread = 1 count5095105115125135145151 LSB = 4.883 mV

An ADC rounds the voltage down to the nearest step: every reading stands for a band one LSB wide.

Voltage at the pin

2.5V

Reading 512 means the voltage lies within one LSB (4.883 mV) above this value.

Results

At the pin
2.5 V
Reading (dec · hex)
512 · 0x200
1 LSB at the pin
4.883 mV
Share of full scale
50 %

Within range: the reading is meaningful.

Code for your board

const int PIN = A0;
const float VREF = 5;
const float STEPS = 1024.0;  // 2^10

void setup() {
  Serial.begin(115200);
}

void loop() {
  int raw = analogRead(PIN);
  float volts = raw * VREF / STEPS;
  Serial.print(raw); Serial.print(" -> "); Serial.println(volts, 3);
  delay(500);
}

Good to know

The reference sets the scale

Every reading is a fraction of Vref. If the Uno's 5 V USB rail is really 4.8 V, all readings are 4% off; a fixed reference (INTERNAL 1.1 V, an external 2.5 V chip) fixes that.

Divide before you measure

To read 12 V on a 3.3 V ADC, put a divider in front: Vpin = Vsource × R2 / (R1 + R2). Keep a margin so the pin never reaches the supply.

Average the last bits

The lowest one or two bits flicker with noise. Average 8–16 samples, or add 100 nF from the pin to GND, before trusting single counts.

ESP32: use the calibrated read

Raw ESP32 counts drift and bend at both ends. analogReadMilliVolts() corrects with the factory calibration; ADC2 pins don't work while Wi-Fi is on.

How an ADC turns volts into a number

An n-bit ADC splits the range from 0 V to the reference into 2ⁿ equal steps and returns the step the input falls in. V = reading × Vref / 2ⁿ, and each count is one LSB wide: 4.9 mV for a 10-bit ADC at 5 V, 0.8 mV for 12 bits at 3.3 V. More bits mean finer steps, but noise, reference accuracy and source impedance usually limit the real precision first.

How ADC readings and number bases work

From a raw reading to volts

V = reading × Vref / 2ⁿ

An n-bit ADC divides the range from 0 V to its reference Vref into 2ⁿ steps. A reading is the number of the step the input falls into, so the pin voltage is reading × Vref / 2ⁿ and each step (one LSB) is Vref / 2ⁿ wide.

An Arduino Uno has a 10-bit ADC at 5 V: 1024 steps of 4.88 mV, readings 0 to 1023. The ESP32, STM32 and RP2040 are 12-bit at 3.3 V: 4096 steps of 0.81 mV. The ADS1115 is a 16-bit signed converter, so single-ended inputs use 32768 steps of its PGA range, for example 125 µV at ±4.096 V.

With a divider in front (R1 from the source to the pin, R2 from the pin to GND), the source is (R1 + R2) / R2 times the pin voltage. The converter's steps grow by the same factor at the source.

In the bits mode the same value is shown in hex, decimal, octal and binary. Signed numbers use two's complement: in 8 bits the top bit counts as −128, so 0xFF reads as 255 unsigned and −1 signed.

Worked example: a 12 V battery on an Arduino Uno

You measure a 12 V battery on A0 through R1 = 10 kΩ and R2 = 4.7 kΩ, with the Uno's 5 V reference.

  1. Divider factor(10 000 + 4 700) / 4 700 = 3.128
  2. Voltage at the pin12 / 3.128 = 3.837 V
  3. Expected readingfloor(3.837 × 1024 / 5) = 785
  4. Back to volts785 × 5 / 1024 × 3.128 = 11.99 V
  5. Resolution at the battery5 / 1024 × 3.128 = 15.3 mV

analogRead(A0) returns about 785. The divider lets you read up to 15.6 V, and each count is about 15 mV of battery voltage.

Common mistakes

  • Dividing by 1023 instead of 1024

    The datasheets give V = reading × Vref / 1024. Using 1023 is a small error (0.1%), but it makes the top count read exactly Vref, which the ADC can never measure.

  • Letting the pin go above the supply

    A divider has to keep the pin below the chip's supply even at the highest source voltage. 12 V straight into a 3.3 V pin destroys it.

  • A divider with huge resistors

    Above about 10 kΩ source impedance the ADC's sampling capacitor doesn't charge fully and readings sag. Use smaller resistors or add 100 nF at the pin.

  • Forgetting read_u16() is scaled

    MicroPython's read_u16() returns 0–65535 on every board. Divide by 65536, not by 4096.

  • Mixing signed and unsigned

    A byte 0xFF from a sensor is −1 in an int8_t and 255 in a uint8_t. Reading a signed register into an unsigned type turns small negatives into large positives.

  • Shifting 1 past bit 30 in C

    On a 32-bit int, 1 << 31 overflows. Write 1UL << 31 for the top bit of a 32-bit mask.

Frequently asked questions

Multiply by the reference and divide by the number of steps: volts = analogRead(A0) × 5.0 / 1024 on an Uno. On a 12-bit board at 3.3 V it is × 3.3 / 4096.

The ESP32 ADC is not linear near 0 V and near the top of each attenuation range, and it varies from chip to chip. Stay inside the usable range (about 0.15–2.45 V at 11 dB) and use analogReadMilliVolts(), which applies the factory calibration.

Use a voltage divider so the pin sees at most about 3 V, for example R1 = 10 kΩ and R2 = 3.3 kΩ (factor 4.03). Multiply the pin voltage by the factor in your code.

It is how signed integers are stored. The top bit counts as a negative weight (−128 in 8 bits), so 0x80 is −128, 0xFF is −1 and 0x7F is 127. To negate a number, invert all its bits and add 1.

The order bytes sit in memory. AVR, ESP32 and ARM are little-endian: 0x1234 is stored as 0x34 then 0x12. Network protocols and many sensors send big-endian, the high byte first.

It is a 16-bit signed converter. Single-ended inputs use 0 to 32767, so at ±4.096 V each count is 125 µV; at ±0.256 V it is 7.8 µV.

Free shipping

On orders over 5000DA

Easy returns

7-day hassle-free returns

Fast checkout

payments on delivery and fast shipping

24/7 support

We're here to help

Dzduino Online Store

Eempowering engineers, students, makers, researchers, and businesses with high-quality and innovative technical solutions.

  • Sales: store@dzduino.com
  • Store: +213 550 88 88 27
  • Sales: +213 550 88 88 29
  • Support: +213 550 88 88 37
  • 043 Cite Remila (Route du Port), Tigditt - Mostaganem

Shop

  • All Categories
  • Électronique & Développement
  • Tools & Equipements & DIY
  • Téléphonie & Communication
  • Fabrication & Prototyping
  • Computers & Networks
  • Power & Energy & Solar
  • Video Surveillance & Security systems
  • Educational, Scientific and Laboratory

Support

  • Track order
  • Orders
  • Account
  • Shipping & returns
  • Shipping calculator

Company

  • About
  • Contact us
  • Site map
  • Privacy
  • Terms

Stay in the loop

New stock, maker deals, and electronics tips — straight to your inbox.

© 2026 Dzduino Electronics, All Rights Reserved

TermsPrivacyShipping & returnsSite map
CIBBARIDI MobFawriPayCash

Related products

Boards, modules, and kits that pair with this tool.

View all
Arduino UNO SMD (Arduino Compatible)
DZD0000520

Arduino UNO SMD (Arduino Compatible)

DZD 1,500.00Out of StockOut of Stock
Arduino DUE ( Compatible) EN
DZD0000530

Arduino DUE ( Compatible) EN

DZD 6,000.00Out of StockOut of Stock
Iteaduino Tiny (Arduino Compatible)
DZD0000540

Iteaduino Tiny (Arduino Compatible)

DZD 900.00Out of StockOut of Stock
Iteaduino Nano (Arduino Compatible)
DZD0000550

Iteaduino Nano (Arduino Compatible)

DZD 2,500.00Out of StockOut of Stock
Iteaduino
DZD0000570

Iteaduino

DZD 1,500.00Out of StockOut of Stock
RBOARD (Relay Board)
DZD0000661

RBOARD (Relay Board)

DZD 4,900.00In StockIn Stock
Screw shield V1.0 for Arduino
DZD00007310

Screw shield V1.0 for Arduino

DZD 1,200.00In StockIn Stock
Joystick shield (Arduino Compatible)
DZD0000740

Joystick shield (Arduino Compatible)

DZD 1,000.00Out of StockOut of Stock
Free express shipping on orders over 10,000DA
SpecialSaleBlogPrint & CutLabContact usToolsNewLabNew