Binary 23 is the base-2 representation of the decimal number 23, written as 10111 in a 5-bit system or 00010111 in a standard 8-bit byte, where each bit corresponds to a specific physical HIGH (e.g., 3.3V or 5V) or LOW (0V) logic state in a digital circuit. When you write this value to a microcontroller register or shift register, it changes the physical voltage state of up to eight distinct output pins simultaneously, dictating everything from relay switching sequences to analog voltage synthesis. Beginners most commonly confuse the binary string 10111 with the decimal number ten thousand one hundred eleven, or they wire the Most Significant Bit (MSB) to the Least Significant Bit (LSB) pin, resulting in completely inverted hardware behavior.
0b (e.g., 0b00010111) and hex with 0x (e.g., 0x17) to prevent the compiler from treating your logic states as base-10 integers.
The Anatomy of Binary 23 (00010111)
In standard 8-bit digital logic—like the architecture of an ATmega328P (Arduino Uno) or a 74HC595 shift register—decimal 23 requires padding with leading zeros to fill the byte. The physical hardware doesn't care about the decimal value; it only sees the voltage presence on specific pins.
| Bit Position | 7 (MSB) | 6 | 5 | 4 | 3 | 2 | 1 | 0 (LSB) |
|---|---|---|---|---|---|---|---|---|
| Binary State | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 1 |
| Decimal Weight | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
| 5V Logic Output | 0V | 0V | 0V | 5V | 0V | 5V | 5V | 5V |
The sum of the active weights (16 + 4 + 2 + 1) equals 23. If you are driving a common anode LED bar graph, those specific four pins will sink current and illuminate, while the others remain dark.
Worked Example: Binary 23 Driving a 5-Bit R-2R DAC
Let’s look at what binary 23 actually does when we use it to synthesize an analog voltage. Suppose you have built a 5-bit R-2R resistor ladder Digital-to-Analog Converter (DAC) using 10kΩ and 20kΩ resistors, connected to pins D0 through D4 on a 5V microcontroller.
The formula for the output voltage of an R-2R ladder is:
V_out = V_ref × (D / 2^n)
- V_ref: 5.0V (assuming a clean, regulated logic supply)
- D: The decimal value of our binary input (23)
- n: The bit-depth of the DAC (5 bits)
- 2^n: 2^5 = 32 total possible steps
Plugging in the real values:
V_out = 5.0V × (23 / 32)
V_out = 5.0V × 0.71875
V_out = 3.59375V
By writing 0b10111 to those five pins, you have instructed the circuit to output exactly 3.59V. If your multimeter reads 3.42V instead, you are likely experiencing voltage sag from the microcontroller's internal pin resistance (often ~25Ω per pin) loading down the ladder, a common issue when using standard 10kΩ resistors without an op-amp buffer.
Where You Meet Binary 23 in Practice
You won't just see this value in textbook DAC examples; it appears constantly in embedded systems and digital logic installations.
Direct Port Manipulation (GPIO Registers)
When you need to toggle multiple pins faster than digitalWrite() allows, you write directly to the hardware registers. Writing PORTD = 23; on an AVR-based board instantly sets the states of Port D pins. However, on the Arduino Uno, Port D includes PD0 (RX) and PD1 (TX). If you write 23 (00010111) to PORTD, you are forcing PD0 and PD1 LOW, which will instantly kill any active Serial communication and potentially cause brownouts if those pins are tied to external USB circuitry.
DDRD). If a pin is accidentally set as an INPUT and you write a HIGH to it via the PORT register, you will activate the internal 20kΩ-50kΩ pull-up resistor, which can cause phantom readings in high-impedance sensor circuits.
Shift Register Cascading
When driving a 74HC595 shift register via SPI or bit-banging, sending the byte 0x17 (hex for 23) shifts the bits into the register's storage. When you pulse the latch pin HIGH, QA through QH update simultaneously. This is heavily used in DIY LED matrix builds and relay-driver boards where you need to conserve microcontroller pins.
Sensor Configuration via I2C
Many I2C sensors, like the BMP280 pressure sensor or MPU6050 accelerometer, use specific hex registers to set thresholds or prescalers. Setting a digital low-pass filter (DLPF) register to 0x17 might configure a specific bandwidth cutoff. In these cases, binary 23 isn't an output state; it's a configuration key mapped in the silicon's lookup table.
Common Pitfalls: Bit-Ordering and Voltage Logic
The most frequent reason a circuit fails when a developer intends to output binary 23 is endianness and pin mapping.
If you are using the Arduino shiftOut() function, you must declare MSBFIRST or LSBFIRST. If your physical wiring connects the shift register's QA pin to your load's Bit 0, but your code shifts MSBFIRST, the hardware will interpret the sequence backward. Your intended 10111 (23) gets read by the physical pins as 11101 (29). In our 5-bit DAC example, outputting 29 instead of 23 changes the analog voltage from 3.59V to 4.53V—a massive 0.94V error that will throw off any downstream analog comparator or motor driver.
Always verify your physical pin mapping against the datasheet's timing diagram. For the TI SN74HC595, QA is the LSB and QH is the MSB. Wire accordingly and match your software shift direction.
Frequently Asked Questions
How do I convert decimal 23 to binary for an Arduino sketch?
You do not need to manually convert it in your code; the compiler handles it. You can write 23 (decimal), 0x17 (hexadecimal), or 0b00010111 (binary literal). The microcontroller's ALU processes them identically as the same 8-bit byte in memory. Use 0b formatting when you want the code to visually represent the physical HIGH/LOW states of a port register for readability.
What happens if I send binary 23 to an 8-bit PWM pin?
If you use analogWrite(pin, 23) on a standard 8-bit PWM pin (like Pin 3 on an Uno), the hardware timer sets the duty cycle to 23 out of 255 steps. This results in a 9.02% duty cycle. If you measure the pin with a true-RMS multimeter or pass it through a low-pass RC filter, the resulting average DC voltage will be approximately 0.45V (assuming a 5V logic high). This is commonly used for dimming LEDs to a very low, but non-zero, brightness level.
Why does my shift register output the wrong pins when I write 23?
This is almost always a mismatch between your software shift direction and your physical wiring. If you write 23 (00010111) using MSBFIRST, the first bit shifted into the register's QA pin will be a 0, and the last bit shifted into QH will be a 1. If your external circuit expects QA to be the 1V weight (LSB), your outputs will be inverted relative to your expectations. Fix this by either changing the shiftOut() parameter to LSBFIRST or physically swapping the data lines on your breadboard to match the MSB-to-QH mapping. Refer to the Arduino Digital Pins documentation for standard shift register wiring practices.
Can I use binary 23 to set a specific baud rate divisor?
Yes, in older UART implementations or specific AVR microcontrollers, the baud rate register (UBRR) relies on integer division of the system clock. While 23 is not a standard divisor for 9600 or 115200 baud at 16MHz, it might be the exact required divisor for non-standard baud rates (like certain MIDI or DMX512 variations) when running on an 8MHz internal oscillator. Always calculate the UBRR value using the formula in the ATmega328P datasheet rather than guessing register values.






