MyRoboPath
electronics15 min readUpdated 2026-03-14Beginner

Understanding Binary Numbers & Digital Logic Levels (TTL vs CMOS)

Master the language of computers and robotics: understand base-2 binary counting, hex representations, bytes/nibbles, and voltage threshold logic standards (5V TTL, 3.3V CMOS, 1.8V Low Voltage).

MyRoboPath Engineering Lab
Peer-Reviewed Open-Source Hardware & Firmware Guide

Key Engineering Takeaways

  • Digital electronics use Base-2 (Binary) because transistors act most reliably as binary switches (Fully ON = 1, Fully OFF = 0).
  • Each binary digit is a Bit; 4 bits make a Nibble, 8 bits make a Byte (0 to 255), and 16 bits make a Word.
  • Hexadecimal (Base-16: 0-9, A-F) is human shorthand for binary: each hex digit represents exactly 4 binary bits (0xFF = 11111111 = 255).
  • A 3.3V HIGH output can safely trigger a 5V TTL input, but a 5V HIGH output WILL DESTROY an unbuffered 3.3V CMOS input pin.
  • Always use bidirectional MOSFET logic level shifters (BSS138) for I2C and UART buses crossing voltage domains.
Prerequisites
  • Basic Voltage and Transistor concepts
Required Hardware / Tools
  • ESP32 (3.3V)
  • Arduino Uno (5V)
  • BSS138 Logic Level Converter Module
  • Breadboard and Multimeter

Why Electronics Use Binary (0 and 1)

While humans count in decimal (Base-10) using ten fingers (0-9), electronic microprocessors operate exclusively in **Binary (Base-2)** using two discrete states: **Formula:** **0** and **1** ### Why Binary? In an analog circuit, trying to distinguish 10 subtle voltage levels (0.5V, 1.0V, 1.5V dots) is extremely vulnerable to electrical noise, temperature drift, and battery voltage sag. In binary, an electronic transistor only has to determine whether a voltage is **HIGH (Switch Closed / V_CC)** or **LOW (Switch Open / 0V)**. This gives digital computers near-infinite noise immunity!
Binary 0 and 1 transistor states
Figure 1.1: Binary transistor states: Cutoff (LOW / 0) vs Saturation (HIGH / 1).Visual Guide

Binary Counting, Place Values & Hexadecimal Conversion

In base-2, each column represents an increasing power of 2 (2^0=1, 2^1=2, 2^2=4, 2^3=8, 2^4=16, 2^5=32, 2^6=64, 2^7=128): **Formula:** **10110110**_2 = 128 + 0 + 32 + 16 + 0 + 4 + 2 + 0 = 182_10 ### Hexadecimal Shorthand (Base-16): Writing 32-bit binary registers is tedious. **Hexadecimal** uses symbols 0-9 and A-F (A=10, B=11, C=12, D=13, E=14, F=15): - Split 8-bit byte into two 4-bit nibbles: **Formula:** 1011_2 = **B**_16 | 0110_2 = **6**_16 → **0xB6** = 182_10
Binary to decimal and hex conversion chart
Figure 1.2: Binary place value table and hexadecimal conversion chart.Visual Guide

Voltage Logic Levels: 5V TTL vs 3.3V CMOS Thresholds

What physical voltages represent a digital `0` and `1`? ### 1. 5V TTL Logic Standard: - **Output LOW (V_OL)**: 0.0V - 0.4V - **Output HIGH (V_OH)**: 2.4V - 5.0V - **Input LOW Threshold (V_IL)**: Must be <0.8V to be recognized as `0`. - **Input HIGH Threshold (V_IH)**: Must be >2.0V to be recognized as `1`. ### 2. 3.3V LVCMOS Standard (ESP32, Raspberry Pi, STM32): - **Input LOW**: <0.8V - **Input HIGH**: >2.0V - **Maximum Safe Input Voltage**: **3.6V MAXIMUM**. > [!WARNING] > **Voltage Domain Incompatibility**: A 3.3V microcontroller output (3.3V) is >2.0V, so a 5V Arduino will read it as a valid HIGH. **BUT connecting a 5V output directly to a 3.3V ESP32 input pin will conduct through the chip's internal ESD protection diodes and destroy the pin!**
5V TTL vs 3.3V CMOS logic level diagram
Figure 1.3: Voltage logic level threshold comparison between 5V TTL and 3.3V CMOS standards.Visual Guide

Level Shifting: Interfacing 3.3V and 5V Microcontrollers Safely

To safely communicate between 3.3V and 5V devices: 1. **Unidirectional (5V TX to 3.3V RX)**: Simple two-resistor voltage divider (1 kΩ + 2 kΩ) drops 5.0V down to 3.3V. 2. **Bidirectional (I2C Bus SDA/SCL)**: Use a **BSS138 N-MOSFET level shifter module**. When either side pulls low, the MOSFET conducts and safely pulls the opposite side low without ever exposing the 3.3V chip to 5V!
MOSFET bidirectional logic level shifter schematic
Figure 1.4: Bidirectional N-MOSFET logic level shifter circuit for I2C communication.Visual Guide

Frequently Asked Questions

What is the "Indeterminate Zone" in digital logic?

The Indeterminate Zone (typically 0.8V to 2.0V in 5V TTL) is the undefined voltage region between valid LOW and HIGH. Voltages floating in this zone cause chips to draw excessive supply current and trigger random erratic logic transitions.

Tags:#Binary#Digital Logic#Logic Levels#TTL#CMOS#Hexadecimal#Microcontrollers