A demultiplexer (demux) is a combinational logic circuit that takes a single data input and routes it to one of several output lines, determined by a set of select pins. If you are drafting a circuit diagram of demux systems for bench prototyping, LED multiplexing, or relay routing, the default component you should reach for is the 74HC138 (a 3-to-8 line decoder/demultiplexer). It handles 95% of DIY and hobbyist routing tasks without requiring the massive breadboard footprint of discrete logic gates.
This guide breaks down the exact topology, provides a concrete design walkthrough with real component values, and maps out the failure modes you will inevitably hit when wiring this IC on a breadboard.
The 74HC138 Topology: Nodes, Pins, and Signal Flow
When you look at a textbook block diagram of a demux, you will see a single 'Data' pin, multiple 'Select' pins, and an array of 'Output' pins. However, when you translate that into a physical Texas Instruments SN74HC138 datasheet, the topology shifts slightly. The 74HC138 does not have a dedicated 'Data In' pin; instead, the data signal is fed into one of the Enable pins.
Here is the exact node mapping for the 16-pin DIP IC:
- Select Nodes ($S_0, S_1, S_2$): Pins 1, 2, and 3. These binary inputs (000 to 111) choose which of the 8 outputs will be active.
- Enable Nodes ($\overline{E_1}, \overline{E_2}, E_3$): Pins 4, 5, and 6. For the chip to function, $\overline{E_1}$ and $\overline{E_2}$ must be LOW, and $E_3$ must be HIGH. Bench Tip: To use this as a demux rather than a static decoder, tie $E_3$ HIGH, tie $\overline{E_2}$ LOW, and feed your actual Data signal into $\overline{E_1}$.
- Output Nodes ($\overline{Y_0}$ to $\overline{Y_7}$): Pins 15 down to 7. Critical: These outputs are active-LOW. The selected output will pull to GND (0V), while all unselected outputs remain HIGH (VCC).
- Power Nodes: VCC (Pin 16) and GND (Pin 8).
Behavior Table: Routing the Input to the Correct Output
Understanding the truth table is where most beginners get tripped up because of the active-low outputs. If your Data input is HIGH, all outputs are HIGH (inactive). The routing only happens when the Data input goes LOW.
| Select ($S_2 S_1 S_0$) | $E_3$ (Pin 6) | $\overline{E_2}$ (Pin 5) | Data In $\overline{E_1}$ (Pin 4) | Active Output Node | Unselected Outputs |
|---|---|---|---|---|---|
| 0 0 0 | HIGH | LOW | LOW (0) | $\overline{Y_0}$ goes LOW | All HIGH |
| 0 0 0 | HIGH | LOW | HIGH (1) | None (All HIGH) | All HIGH |
| 0 1 1 | HIGH | LOW | LOW (0) | $\overline{Y_3}$ goes LOW | All HIGH |
| 1 0 1 | HIGH | LOW | LOW (0) | $\overline{Y_5}$ goes LOW | All HIGH |
| X X X | LOW | X | X | None (Chip Disabled) | All HIGH |
Design Walkthrough: 1-to-8 Active-Low LED Router
Let's build a practical circuit that routes a 5V PWM signal from a microcontroller to one of eight indicator LEDs. Because the 74HC138 outputs are active-LOW and can only sink about 4mA to 6mA reliably (depending on the specific manufacturer's datasheet specifications), we must wire the LEDs in a current-sinking configuration.
Component List:
- 1x CD74HC138E (DIP-16 package)
- 8x Standard 5mm Red LEDs (Forward voltage ~2.0V)
- 8x 330Ω resistors (1/4W)
- 1x 0.1µF ceramic bypass capacitor
Wiring Steps:
- Power and Bypass: Connect Pin 16 to your 5V rail and Pin 8 to GND. Place the 0.1µF capacitor directly across Pins 16 and 8 to suppress high-frequency switching noise.
- Select Lines: Connect Pins 1, 2, and 3 to three digital output pins on your microcontroller (e.g., Arduino D2, D3, D4).
- Enable / Data Lines: Tie Pin 6 ($E_3$) directly to 5V. Tie Pin 5 ($\overline{E_2}$) directly to GND. Connect Pin 4 ($\overline{E_1}$) to your microcontroller's PWM output pin.
- LED Array (The Active-Low Trick): Connect the anodes (long legs) of all 8 LEDs directly to the 5V rail. Connect the cathodes (short legs) to one side of the 330Ω resistors. Connect the other side of the resistors to the output pins ($\overline{Y_0}$ through $\overline{Y_7}$).
With a 5V supply and a 2.0V LED forward voltage, the voltage drop across the resistor is 3.0V. Using Ohm's Law ($I = V/R$), $3.0V / 330Ω = 9mA$. This is well within the 74HC138's maximum sink current per pin (typically 25mA absolute max, but 6mA recommended for guaranteed logic levels) and provides plenty of brightness for indicator duty.
Decision Tree: Discrete Gates vs. 74HC138 vs. 74HC154
Why use a dedicated demux IC instead of building one from NAND gates or just using more microcontroller pins? Use this decision matrix to lock in your topology.
| Criteria | Discrete Logic (74HC00/04) | 74HC138 (3-to-8 Demux) | 74HC154 (4-to-16 Demux) |
|---|---|---|---|
| Output Count | Any (Custom) | Up to 8 | Up to 16 |
| IC Count Required | 4 to 6 ICs | 1 IC | 1 IC |
| Breadboard Footprint | Massive (prone to wiring errors) | Compact (16-pin DIP) | Wide (24-pin DIP) |
| Propagation Delay | Cumulative (gate-to-gate) | ~20ns (single stage) | ~25ns (single stage) |
The Final Pick: If you need to route a signal to 8 or fewer destinations, use the 74HC138. It saves board space, eliminates cumulative propagation delay, and costs less than $0.50. If you need 9 to 16 destinations, step up to the 74HC154. Only use discrete gates if you are specifically trying to learn Boolean algebra reduction; never use them for a functional product design.
Failure Modes at the Extremes: Shorts, Opens, and Floating Pins
When your circuit doesn't work, it is usually due to one of these three physical layer failures. Here is what breaks and how it manifests.
- Floating Enable Pin ($\overline{E_1}$ or $\overline{E_2}$): CMOS inputs have incredibly high impedance. If you forget to tie an unused enable pin to a defined logic level, it will float. Ambient electromagnetic noise will cause it to randomly read HIGH and LOW. Symptom: LEDs flicker erratically or stay completely dead. Fix: Never leave CMOS inputs floating; tie them to VCC or GND with a direct wire or a 10kΩ pull-up/pull-down resistor.
- Select Line Shorted to VCC: If $S_0$ (Pin 1) accidentally shorts to the 5V rail, the chip will interpret that bit as a permanent '1'. Symptom: You will only ever be able to select odd-numbered outputs ($\overline{Y_1}, \overline{Y_3}, \overline{Y_5}, \overline{Y_7}$). The even outputs will remain dead regardless of your code.
- Output Shorted to Ground: If one of the $\overline{Y}$ pins shorts to GND on the breadboard. Symptom: The LED on that specific channel will remain permanently illuminated, even when the select lines point to a different channel, because the node is physically clamped to 0V.
Step-by-Step Breadboard Verification
Do not just plug in the microcontroller and hope the code works. Verify the hardware layer first using a multimeter and a manual logic probe (a jumper wire).
- Power Verification: Before inserting the IC, use your multimeter to verify exactly 5.0V (±0.2V) between the VCC and GND rails on the breadboard.
- Static Enable Test: Insert the IC. Tie $S_0, S_1, S_2$ to GND. Tie $E_3$ to 5V. Tie $\overline{E_2}$ to GND. Leave $\overline{E_1}$ disconnected for a moment, then tap it to GND. The LED on $\overline{Y_0}$ should light up only when $\overline{E_1}$ touches GND.
- Select Line Sweep: Tie $\overline{E_1}$ permanently to GND. Using a jumper wire, manually step the select pins through binary 000 to 111. Watch the LEDs light up sequentially from $\overline{Y_0}$ to $\overline{Y_7}$. If the sequence skips or lights the wrong LED, your $S_0/S_1/S_2$ wiring is swapped.
- PWM Injection: Once the manual sweep passes, connect your microcontroller. Output a 500Hz PWM signal at 50% duty cycle to the $\overline{E_1}$ pin. The currently selected LED should visibly dim to half brightness, proving the demux is successfully passing the analog-timed signal through the digital gate.






