Binary representation is a base-2 numeral system where every numeric value is expressed using only two symbols, 0 and 1, which directly map to the low and high voltage states of digital electronic circuits.
The Core Mechanism: Voltage as a Number
In physical electronics, binary representation changes how we interface abstract mathematics with real-world silicon. A '0' or '1' is never a perfect 0.000V or 5.000V. Instead, binary logic relies on voltage thresholds and noise margins to determine state. When you write a 1 to a microcontroller register, you are commanding a MOSFET gate to pull a pin to the logic high voltage ($V_{CC}$). When the receiving logic gate reads that pin, it checks if the voltage exceeds the input high threshold ($V_{IH}$).
For a standard 5V CMOS logic family, a valid logic '1' might be anything from 3.5V to 5.0V, while a logic '0' is 0V to 1.5V. The gap between 1.5V and 3.5V is the undefined region. If voltage drop across a long wire causes your 5V signal to sag to 2.8V at the receiver, the binary representation breaks down—the hardware cannot reliably decide if the bit is a 0 or a 1. This is why understanding binary is not just about math; it is about managing physical signal integrity, impedance, and voltage drop in your wiring.
Worked Numeric Example: Configuring an 8-Bit Port Register
Let's look at a concrete bench scenario. You are using a TI SN74HC595 8-bit shift register to control eight separate indicator LEDs. The shift register takes a serial binary stream and outputs it in parallel across pins Q0 through Q7. You need to turn on the LEDs connected to Q0, Q3, and Q7, while keeping the rest off.
To do this, we construct an 8-bit binary word. The most significant bit (MSB) corresponds to Q7, and the least significant bit (LSB) corresponds to Q0.
| Bit Position | Output Pin | Decimal Weight | Desired State | Calculated Value |
|---|---|---|---|---|
| 7 (MSB) | Q7 | 128 | ON (1) | 128 |
| 6 | Q6 | 64 | OFF (0) | 0 |
| 5 | Q5 | 32 | OFF (0) | 0 |
| 4 | Q4 | 16 | OFF (0) | 0 |
| 3 | Q3 | 8 | ON (1) | 8 |
| 2 | Q2 | 4 | OFF (0) | 0 |
| 1 | Q1 | 2 | OFF (0) | 0 |
| 0 (LSB) | Q0 | 1 | ON (1) | 1 |
Reading the 'Desired State' column from MSB to LSB gives us the binary sequence: 10001001. To send this over SPI or I2C from a microcontroller, we usually convert it to decimal or hexadecimal. Summing the 'Calculated Value' column (128 + 8 + 1) gives us a decimal value of 137. In hexadecimal, this is 0x89. In your Arduino or ESP32 code, you would write shiftOut(dataPin, clockPin, MSBFIRST, 0x89); to achieve this exact physical pin configuration.
Where You Meet Binary Representation in Practice
Beyond simple GPIO toggling, binary representation dictates how we configure and address complex subsystems on the bench.
- I2C Device Addressing: The I2C protocol uses a 7-bit binary address to identify devices on the bus. If you wire up a PCF8574 I/O expander, it has three physical pins (A0, A1, A2) that hardwire the lowest three bits of its address. Tying A0 to VCC (binary 1) and A1/A2 to GND (binary 0) changes the address from the base
0x20to0x21. This physical-to-binary mapping allows you to daisy-chain up to eight identical chips on the same two wires. - Stepper Motor Driver DIP Switches: Industrial stepper drivers like the DM542 use physical DIP switches to set the peak current and microstepping resolution. The manual provides a truth table where a bank of 4 switches represents a 4-bit binary fraction of the maximum current. Switching to binary '0110' might set the current to 60% of the driver's maximum rating.
- ADC Resolution and Quantization: When an analog sensor reads a voltage, the Analog-to-Digital Converter (ADC) maps it to a binary number. The ESP32 Technical Reference Manual details its 12-bit SAR ADC, meaning it outputs a 12-bit binary number ranging from
000000000000to111111111111(0 to 4095 in decimal). With a 3.3V reference, each binary step represents exactly 0.805mV. If your sensor outputs 1.65V, the ADC returns a binary value of approximately 2048.
Common Confusions: Binary vs. Hexadecimal vs. BCD
People commonly confuse binary representation with hexadecimal notation and Binary-Coded Decimal (BCD). It is vital to separate the underlying physical state from the human-readable shorthand.
Hexadecimal (Base-16) is not a different physical state; it is simply a compression tool for human readability. Because 16 is a power of 2 ($2^4$), exactly four binary bits map to one hex digit. The binary sequence 1111 1010 is tedious to read, so we group it and write it as 0xFA. The microcontroller does not process 'F' or 'A'; it processes the exact same high and low voltages as the binary string.
Binary-Coded Decimal (BCD), on the other hand, is a specific encoding scheme that wastes binary states to mimic human decimal counting. In standard 4-bit binary, you can count from 0 to 15. In BCD, the states from 1010 (10) to 1111 (15) are considered invalid. BCD is heavily used in legacy digital displays and RTC (Real Time Clock) modules like the DS3231, where the time registers store '59' seconds as 0101 1001 rather than the pure binary equivalent of 59 (0011 1011). Confusing pure binary with BCD when reading an I2C RTC register will result in completely incorrect time calculations in your code.
Frequently Asked Questions
Why do microcontrollers use binary representation instead of decimal?
Microcontrollers use binary because the fundamental building block of digital logic—the MOSFET transistor—operates as a switch with two stable states: cutoff (high resistance, low voltage) and saturation (low resistance, high voltage). Designing a silicon circuit that reliably distinguishes between 10 distinct voltage levels (for base-10 decimal) on a single wire would require impossibly tight noise margins, massive power consumption, and complex analog comparison circuitry. Binary representation aligns perfectly with the physical reality of two-state semiconductor switching.
How does binary representation affect ADC resolution in sensors?
The bit-depth of an ADC determines how many discrete binary steps are available to map an analog voltage range. A 10-bit ADC (like on the ATmega328P) provides $2^{10}$ or 1,024 binary steps. A 16-bit ADC provides $2^{16}$ or 65,536 steps. Higher binary resolution reduces quantization error—the inherent inaccuracy caused by rounding a continuous analog voltage to the nearest available discrete binary step. When selecting an ADC for a precision load cell or thermocouple, you must calculate whether the voltage change per unit of measurement exceeds the voltage weight of the ADC's least significant bit (LSB).
What happens if a binary sequence exceeds the register size?
If you attempt to write a value larger than the register can hold, you trigger an overflow. In an 8-bit register, the maximum binary value is 11111111 (255). If your code attempts to write 256 (1 00000000), the 9th bit is truncated because there is no physical memory address to hold it. The register wraps around and stores 00000000 (0). In motor control or timing loops, failing to account for binary overflow can cause a PWM duty cycle to suddenly drop to 0% or a timer to reset unexpectedly, leading to erratic physical behavior in your circuit.






