A multiplexer in digital electronics is a combinational logic circuit that selects one of several input signals and forwards it to a single output line based on the state of its select pins. Rather than dwelling on the telecom switching origins of the 1950s, let us look at what this component actually buys you on the workbench: it acts as a digitally controlled rotary switch, allowing a microcontroller with limited GPIO to read dozens of sensors or route multiple data streams without needing a massive pin count.

How a Multiplexer Changes Your Circuit Design

When you introduce a multiplexer (often abbreviated as MUX) into a real circuit, the primary thing it changes is the physical wiring topology and the microcontroller's pin budget. It performs parallel-to-serial conversion at the hardware level. If you are building a CNC machine with 16 limit switches, wiring each switch to a dedicated Arduino or ESP32 pin requires 16 GPIO pins, 16 pull-up resistors, and a massive cable harness. By inserting a 16-to-1 multiplexer, you reduce that to just 4 select pins and 1 data pin.

Think of it like a multi-lane highway merging into a single toll booth; the select lines act as the traffic lights dictating which lane gets to pass through at any given millisecond. The microcontroller rapidly toggles the select lines, reading the single output pin each time, effectively polling multiple inputs sequentially.

Bench Tip: Always place a 100nF (0.1µF) ceramic decoupling capacitor across the VCC and GND pins of your multiplexer IC, as close to the chip body as possible. Fast toggling of the select lines causes momentary current spikes that can induce ground bounce and false triggering on adjacent logic gates if the local power rail is not stiff.

Worked Numeric Example: Wiring a 74HC151 8-to-1 MUX

Let us look at a concrete numeric example using the Texas Instruments SN74HC151, a standard 8-to-1 digital multiplexer. This IC has eight data inputs (D0 through D7), three select lines (A, B, C), and one primary output (Y).

Suppose you have a temperature sensor wired to input D6, and you want to route its signal to the output Y. The select lines A, B, and C represent a 3-bit binary number that dictates which input is chosen. To select D6, we need the binary equivalent of 6, which is 110.

  • C (MSB) = 1 (High / VCC)
  • B = 1 (High / VCC)
  • A (LSB) = 0 (Low / GND)

By driving the select pins to C=1, B=1, A=0, the internal logic gates connect D6 directly to Y. But what about timing? According to the datasheet, at a 5V supply and 25°C ambient, the SN74HC151 has a typical propagation delay ($t_{pd}$) of 18 ns, and a maximum of 28 ns. If your application requires reading a high-speed digital bus, this delay matters.

If you need 16 inputs, you can cascade two 74HC151 chips. The first MUX handles inputs 0-7, the second handles 8-15, and their outputs feed into a third MUX or an OR gate. In a two-stage cascade, the worst-case propagation delay stacks. Maximum cascaded delay = 28 ns (Stage 1) + 28 ns (Stage 2) = 56 ns. While 56 ns is negligible for polling a slow I2C temperature sensor, it will severely distort a 20 MHz SPI clock signal. For high-speed routing, you must select specialized low-latency bus multiplexers like the SN74CBT3257.

Where You Meet Multiplexers in Practice

You will encounter multiplexing logic across almost every embedded systems domain. Below is a breakdown of the specific ICs and modules you will reach for depending on the signal type you are trying to route.

Signal Type Common Part Number Typical Cost (2026) Primary Use Case
Digital Logic (5V/3.3V) SN74HC151 / 74HC4051 $0.40 - $0.70 Routing digital buttons, limit switches, or SPI chip-select lines.
Analog Voltages CD4051B / MAX4051 $0.50 - $1.20 Reading multiple analog sensors (NTC thermistors, potentiometers) into a single MCU ADC pin.
I2C Bus Data TCA9548A (Adafruit/NXP) $4.50 - $6.00 Resolving I2C address collisions when using multiple identical sensors (e.g., three BME280s with the same hardcoded address).

The I2C multiplexer deserves special mention. As documented in Adafruit's TCA9548A guide, standard I2C sensors often have only one or two alternate address pins. If you need eight BME280 environmental sensors on a single Raspberry Pi Pico, an I2C MUX acts as a digital traffic cop, isolating the SDA/SCL lines to only the specific sensor channel you are currently querying, completely eliminating address conflicts.

Clearing the Confusion: MUX vs. DEMUX vs. Encoder

When ordering parts or reading schematics, beginners frequently confuse the multiplexer with its close logical relatives. Here is how to tell them apart on a datasheet:

  • Multiplexer (MUX): Many inputs, one output. Requires select lines to choose the path. (Data flows Many $ ightarrow$ One).
  • Demultiplexer (DEMUX): One input, many outputs. Requires select lines to choose the destination. The 74HC138 is a classic example, often used to drive individual LED segments or enable specific memory chips. (Data flows One $ ightarrow$ Many).
  • Encoder: Many inputs, fewer outputs (binary code). Unlike a MUX, an encoder does not use select lines. It simply looks at which input pin is currently HIGH and outputs the binary address of that pin. The 74HC148 is a priority encoder; if multiple inputs are HIGH, it outputs the binary code for the highest-priority pin. (Data flows State $ ightarrow$ Binary Code).

For a deeper theoretical breakdown of how these combinational circuits map to boolean algebra, All About Circuits provides an excellent chapter on digital multiplexing logic gates.

Frequently Asked Questions

Can I use a digital multiplexer for analog audio signals?

No. Standard digital multiplexers like the 74HC151 are designed for discrete logic levels (0V and 5V). If you feed an AC audio signal (which swings negative) into a digital MUX, the internal protection diodes will clamp the negative voltage, severely distorting the audio and potentially destroying the IC. For analog signals, you must use an analog multiplexer (like the CD4051B or MAX4051), which uses internal MOSFET pass-gates capable of bidirectional analog voltage routing within the limits of its power rails.

How do I handle unused input pins on a multiplexer IC?

Never leave unused CMOS inputs floating. A floating input acts as an antenna, picking up electromagnetic noise and causing the internal logic gates to oscillate rapidly between HIGH and LOW. This creates 'shoot-through' current, where both the PMOS and NMOS transistors in the inverter stage turn on simultaneously, leading to excessive heat and chip failure. Always tie unused data inputs to either GND or VCC via a direct connection or a 10kΩ resistor.

What happens if I change the select lines while the output is being read?

When you transition the select lines (e.g., moving from binary 011 to 100), the select pins do not change state at the exact same picosecond due to micro-skew in your microcontroller's GPIO toggling. During this transition, the MUX may briefly connect to an unintended intermediate input channel, causing a 'glitch' or spike on the output. In slow sensor polling, this is irrelevant because you add a software delay before reading the ADC. In high-speed digital routing, this glitch can corrupt data packets, requiring you to use a flip-flop to latch the output or a specialized 'make-before-break' multiplexer.

Do multiplexers require pull-up or pull-down resistors?

The select lines (A, B, C) should generally have 10kΩ pull-down or pull-up resistors if they are driven by a microcontroller. When an MCU like the ESP32 or Arduino boots up, its GPIO pins are in a high-impedance (floating) state before your `setup()` code runs. Without pull resistors, the MUX select lines will float, causing the output to rapidly cycle through random inputs, which can trigger unintended actions in downstream circuits like motor drivers or relays. The data output pin (Y) only needs a pull-up if it is driving an open-collector bus or a specific logic family that requires it.