A binary and hexadecimal table maps base-10 integers to base-2 (binary) and base-16 (hex) formats, serving as the foundational lookup for microcontroller register manipulation, I2C addressing, and bitwise logic. In embedded systems, you use hexadecimal to read memory pointers and I2C addresses, and binary to configure hardware registers via bitwise operators. The table below provides the complete 8-bit mapping, prioritizing the boundary values and bit-masks most frequently queried by Arduino and ESP32 developers.
How to Read This Binary and Hexadecimal Table
Before jumping to the data, understand the assumptions and columns used in this reference chart. This table assumes an 8-bit unsigned integer format (0 to 255), which is the standard byte width for GPIO port registers, I2C addresses, and SPI command bytes.
- Decimal: The human-readable base-10 value. Used primarily for setting PWM duty cycles (0-255) or ADC thresholds.
- 8-Bit Binary: The base-2 representation, padded to 8 bits. Used for visualizing bitwise operations (AND, OR, XOR) and hardware register states.
- Hexadecimal: The base-16 representation, prefixed with
0x. Used for I2C device addresses, memory pointers, and color codes. - Bitmask / Use Case: The practical application of this specific value in embedded C/C++ programming.
0011 1100 instead of 00111100). This instantly maps to the hex digits 3 and C, saving you from doing mental math while probing a live bus.
The Complete 8-Bit Reference Chart
The following table covers the fundamental 0-15 sequence (the base hex nibble) and the critical power-of-2 boundaries used in 8-bit register mapping. Data conventions align with Arduino Bitwise Reference and standard ISO/IEC 80000-13 binary prefix definitions. Bookmark the specific id anchors for quick lookups.
| Decimal | 8-Bit Binary | Hexadecimal | Common Embedded Use Case |
|---|---|---|---|
| 0 | 0000 0000 | 0x00 | Clear register / GPIO LOW |
| 1 | 0000 0001 | 0x01 | Bit 0 mask (1 << 0) |
| 2 | 0000 0010 | 0x02 | Bit 1 mask (1 << 1) |
| 3 | 0000 0011 | 0x03 | Lower 2-bit mask |
| 4 | 0000 0100 | 0x04 | Bit 2 mask (1 << 2) |
| 5 | 0000 0101 | 0x05 | Alternating low nibble |
| 6 | 0000 0110 | 0x06 | Standard I2C control byte |
| 7 | 0000 0111 | 0x07 | Lower 3-bit mask (0x07) |
| 8 | 0000 1000 | 0x08 | Bit 3 mask (1 << 3) |
| 9 | 0000 1001 | 0x09 | Common I2C register pointer |
| 10 | 0000 1010 | 0x0A | Line feed / SPI command |
| 11 | 0000 1011 | 0x0B | Config register default |
| 12 | 0000 1100 | 0x0C | Bit 2 & 3 mask |
| 13 | 0000 1101 | 0x0D | Carriage return (UART) |
| 14 | 0000 1110 | 0x0E | Lower 3 bits inverted |
| 15 | 0000 1111 | 0x0F | Lower nibble mask (0x0F) |
| 16 | 0001 0000 | 0x10 | Bit 4 mask (1 << 4) |
| 32 | 0010 0000 | 0x20 | Bit 5 mask / Space char |
| 39 | 0010 0111 | 0x27 | PCF8574 I2C LCD Address |
| 64 | 0100 0000 | 0x40 | Bit 6 mask (1 << 6) |
| 60 | 0011 1100 | 0x3C | SSD1306 OLED I2C Address |
| 127 | 0111 1111 | 0x7F | Max 7-bit signed integer |
| 128 | 1000 0000 | 0x80 | Bit 7 mask (MSB set) |
| 255 | 1111 1111 | 0xFF | Full byte mask / GPIO HIGH |
Applying the Table to Microcontroller Registers
Which Column Applies to Your Installation
Your 'installation' in embedded systems is the specific hardware bus or code block you are manipulating. Use the Hexadecimal column when configuring I2C addresses (e.g., initializing a Wire library with 0x3C) or reading memory-mapped registers in the Espressif ESP32 Technical Reference Manual. Use the Binary column when writing bitwise logic to toggle specific pins without affecting others (e.g., REG |= 0b00000100). Use the Decimal column strictly for human-facing outputs, like mapping an analog sensor reading to a 0-255 PWM duty cycle.
How Logic Thresholds and Masking 'Derate' the Base Value
In wire ampacity tables, derating reduces current capacity based on heat. In digital logic, the equivalent concept is how voltage thresholds and bitwise masking modify the effective base value. A binary 1 is not universally a 1. If you are driving an ESP32-WROOM-32 GPIO pin (3.3V CMOS logic), the datasheet specifies a high-level input voltage (VIH) minimum of roughly 2.3V. If your signal source is a 1.8V sensor, the physical voltage 'derates' your logical 1 down to a 0 (unrecognized). Furthermore, applying a bitmask like & 0x0F derates an 8-bit value down to a 4-bit nibble, intentionally stripping the upper four bits to isolate a specific sensor reading.
What This Table Cannot Tell You
This chart assumes standard unsigned, big-endian byte ordering. It cannot tell you:
- Endianness: Whether a 16-bit value like
0x1234is stored in memory as12 34(Big-Endian) or34 12(Little-Endian). The ESP32 (Xtensa LX6) is Little-Endian. - Signed vs. Unsigned: The binary
1111 1111is255in unsigned math, but-1in Two's Complement signed math. Always cast your variables explicitly in C++. - Floating Point: Hexadecimal representations of floats follow the IEEE 754 Standard. The hex value
0x41200000does not equal decimal 1,092,616,192 in this context; it represents the float10.0.
Frequently Asked Questions
How do I convert a hexadecimal I2C address to binary for bit-banging?
Break the hex address into two nibbles. Take the common SSD1306 OLED address 0x3C. The first digit 3 maps to 0011, and the second digit C (which is 12 in decimal) maps to 1100. Combine them to get 0011 1100. When bit-banging I2C over GPIO pins, you shift this binary value left, reading the Most Significant Bit (MSB) first to toggle your SDA and SCL lines.
Why does my ESP32 read 0xFFFFFFFF instead of a standard hex value?
If you are reading a sensor via SPI or I2C and receive 0xFFFFFFFF (all binary 1s), it rarely means the actual value is 4,294,967,295. In embedded diagnostics, a bus reading all 1s indicates a floating bus or a disconnected device. The internal pull-up resistors are pulling the data line HIGH because the slave device is not acknowledging or driving the line LOW. Check your wiring, verify the slave device has power, and ensure your I2C/SPI clock speed isn't exceeding the sensor's maximum rating.
What is the fastest way to toggle a single bit using this binary and hexadecimal table?
Use the bitwise XOR operator (^) combined with a bit-shift. If you want to toggle Bit 3 on a hardware register, look up Bit 3 in the table: Decimal 8, Hex 0x08, Binary 0000 1000. In your code, write REG ^= (1 << 3);. If the bit was 0, XOR makes it 1. If it was 1, XOR makes it 0. This avoids the need for if/else conditional checks, executing in a single CPU clock cycle.






