The binary and hexadecimal chart is the foundational lookup tool for embedded systems, mapping 8-bit bytes across Base-2 (binary), Base-10 (decimal), and Base-16 (hex). For microcontroller development, the direct rule is simple: use Hexadecimal for memory addresses and I2C/SPI protocols, use Binary for GPIO pin masks and bitwise logic, and use Decimal only for human-readable math like PWM duty cycles or analog sensor scaling.
The Complete Binary and Hexadecimal Chart (Nibble & Bitmask)
Rather than scrolling through 256 rows of redundant data, professional embedded engineers use the standard IEEE 8-bit byte composition model. The chart below provides the complete 4-bit nibble mapping and the complete 8-bit power-of-two bitmask table. Any 8-bit byte (0x00 to 0xFF) is constructed by combining two nibbles (e.g., 0x5A is the 0x50 row plus the 0x0A row). This structure conforms to standard Base-16/Base-2 mathematical mapping conventions outlined in digital logic standards like All About Circuits Digital Logic and Espressif ESP-IDF documentation.
0x). The 'Binary' column is your bitwise operation format (prefix with 0b). The 'Bitmask' section shows the exact binary state when shifting a single bit across an 8-bit register, which is how you isolate or trigger specific hardware pins.
| Hex (0x) | Decimal | Binary (0b) | Bitmask Shift (1 << n) | Hex Mask |
|---|---|---|---|---|
| 0x0 | 0 | 0000 | n=0 (Bit 0) | 0x01 |
| 0x1 | 1 | 0001 | n=1 (Bit 1) | 0x02 |
| 0x2 | 2 | 0010 | n=2 (Bit 2) | 0x04 |
| 0x3 | 3 | 0011 | n=3 (Bit 3) | 0x08 |
| 0x4 | 4 | 0100 | n=4 (Bit 4) | 0x10 |
| 0x5 | 5 | 0101 | n=5 (Bit 5) | 0x20 |
| 0x6 | 6 | 0110 | n=6 (Bit 6) | 0x40 |
| 0x7 | 7 | 0111 | n=7 (Bit 7) | 0x80 |
| 0x8 | 8 | 1000 | (Upper nibble starts) | |
| 0x9 | 9 | 1001 | Shift left by 4 bits | |
| 0xA | 10 | 1010 | e.g., 0xA << 4 = 0xA0 | |
| 0xB | 11 | 1011 | ||
| 0xC | 12 | 1100 | ||
| 0xD | 13 | 1101 | ||
| 0xE | 14 | 1110 | ||
| 0xF | 15 | 1111 | ||
Decision Path: Which Base Applies to Your Protocol?
Choosing the wrong base leads to unreadable code and compilation errors. Use this decision tree to lock in the correct format for your specific hardware interface. This path terminates in a concrete syntax pick for your IDE.
| Hardware Task | Condition / Protocol | Concrete Pick (Syntax) | Example (ESP32/Arduino) |
|---|---|---|---|
| Sensor Addressing | I2C Bus (e.g., BME280, MPU6050) | Hexadecimal | Wire.beginTransmission(0x76); |
| Pin Manipulation | Direct GPIO Register Masking | Binary | GPIO.out_w1ts = 0b00000100; |
| Memory / Flash | SPI NOR Flash Commands | Hexadecimal | SPI.transfer(0x9E); // Read JEDEC ID |
| Analog / PWM | Duty Cycle or ADC Scaling | Decimal | ledcWrite(0, 2048); // 50% of 4096 |
| Character Data | UART / Serial Text Strings | ASCII / Hex | Serial.write(0x0A); // Line feed |
Modifying Base Values: Bit-Shifting and Masking
In electrical wiring, derating factors modify the base ampacity of a conductor based on temperature and bundling. In digital logic, bit-shifting and masking operations modify the base binary/hex value to target specific hardware registers without altering surrounding data.
When you look up a value in the binary and hexadecimal chart, you rarely use it raw. You modify it using C/C++ bitwise operators to fit the microcontroller's 32-bit or 8-bit register boundaries.
- Left Shift (
<<): Multiplies the base value by powers of 2. If your chart shows the bitmask for Bit 2 is0x04(0b00000100), shifting it left by 4 positions (0x04 << 4) yields0x40(0b01000000). This is how you move a configuration bit from a low-byte register to a high-byte register. - Right Shift (
>>): Divides the base value. Used to extract high-nibble data. If an I2C sensor returns0xA5and you only need the top 4 bits, shifting right (0xA5 >> 4) yields0x0A. - Bitwise AND (
&): Acts as a filter mask. To check if Bit 3 is set in a status register reading0x3C, you AND it with the chart's Bit 3 mask:0x3C & 0x08. If the result is non-zero, the bit is high. - Bitwise OR (
|): Forces bits high without clearing others. To set Bit 1 and Bit 2 high simultaneously, OR their chart masks:0x02 | 0x04 = 0x06(0b00000110).
What This Chart Cannot Tell You (Edge Cases & Pitfalls)
The binary and hexadecimal chart is a pure mathematical mapping. It is blind to physical hardware realities and compiler interpretations. Before flashing your firmware, account for these three limitations:
- Endianness (Byte Order): The chart maps single bytes. It cannot tell you how a 16-bit or 32-bit integer is stored in memory. An ESP32 (Xtensa/RISC-V architecture) is typically Little-Endian. If you write the 16-bit hex value
0x1234to memory, it is physically stored as0x34followed by0x12. Always verify your target IC's endianness when sending multi-byte SPI/I2C payloads. - Signed vs. Unsigned (Two's Complement): The chart shows
0xFFas decimal 255. However, if your C++ variable is declared as anint8_t(signed 8-bit integer), the compiler interprets0xFFas -1. The binary pattern is identical (11111111), but the mathematical behavior in your code will cause catastrophic errors if you use it for threshold comparisons. - Physical Voltage Mapping: A logic '1' (binary 1) in the chart does not specify voltage. On an Arduino Uno, a '1' maps to 5V. On an ESP32-WROOM-32, a '1' maps to 3.3V. Feeding a 5V '1' into an ESP32 GPIO pin will destroy the silicon. The chart defines logic states, not electrical characteristics.
Quick-Jump Reference: Most Queried Hex and Binary Values
Bookmark this section. These specific byte values appear constantly in embedded debugging, protocol initialization, and memory wiping. Knowing them by heart saves time when reading logic analyzer traces.
| Hex | Binary | Common Embedded Use Case |
|---|---|---|
| 0x00 | 00000000 | Ground / Clear: Used to reset registers, clear interrupt flags, or initialize memory buffers to a known zero state. |
| 0x55 | 01010101 | UART Auto-Baud: The alternating bit pattern is universally used by bootloaders to detect serial baud rates via the first falling edge timing. |
| 0xAA | 10101010 | SPI Flash Dummy: Standard dummy byte sent during SPI read operations to clock out data, and used in specific NOR flash erase commands. |
| 0x7F | 01111111 | Max Positive Signed: The maximum positive value for an 8-bit signed integer (+127). Often used as a max-limit cap in motor control PWM. |
| 0x80 | 10000000 | Sign Bit / MSB: Sets the Most Significant Bit. In I2C, setting this bit often triggers a 'Read' operation or a register auto-increment flag. |
| 0xFF | 11111111 | Pull-Up / Erased Flash: The default state of an unprogrammed EEPROM/Flash byte. Also used as the I2C General Call address and SPI bus idle state. |
By mastering the composition of nibbles and the specific behavioral quirks of bitwise modification, you eliminate the guesswork from register-level programming. Keep your hex prefixes explicit, respect your compiler's signed/unsigned boundaries, and let the decision tree dictate your syntax.






