Component guide · Intermediate · 3 min read
Analog Multiplexers
CD4051 and CD74HC4067
By Geekobot Learning Team · Updated 24 Oct 2026
On this page
An analog multiplexer is an electronic rotary switch. Select lines choose which of its 8 (CD4051) or 16 (CD74HC4067) channels connects to one common pin. Connect the common pin to an analog input and you can read 16 sensors with one ADC pin and four digital pins. It passes signals both ways, so it also routes digital signals, but it adds some resistance and needs a short settling time.
Key specs at a glance
- CD74HC4067
- 16 channels, 4 select lines (S0 to S3), EN active low
- CD4051 / 74HC4051
- 8 channels, 3 select lines
- Supply
- 2 to 6 V for HC types; signals must stay within the supply
- On-resistance
- Roughly 70 to a few hundred ohms depending on supply
- Direction
- Bidirectional: use as mux or demux
- Uses
- Many pots, sensors, FSRs, soil probes or buttons on few pins
Wiring
Connect VCC and GND, tie EN (enable) to GND, connect S0 to S3 to four digital pins, and SIG (common) to an analog pin. Sensors connect to C0 to C15. Run the multiplexer from the same voltage as your ADC reference, 3.3 V on an ESP32 or Pico, so signals stay in range.
Reading all 16 channels
Set the select pins, wait a moment, then read.
const byte S[4] = {4, 5, 6, 7};
const int SIG = A0;
void setup() {
Serial.begin(115200);
for (byte i = 0; i < 4; i++) pinMode(S[i], OUTPUT);
}
int readChannel(byte ch) {
for (byte i = 0; i < 4; i++) digitalWrite(S[i], (ch >> i) & 1);
delayMicroseconds(10); // let the input settle
analogRead(SIG); // discard first reading
return analogRead(SIG);
}
void loop() {
for (byte ch = 0; ch < 16; ch++) {
Serial.print(readChannel(ch)); Serial.print(ch < 15 ? ',' : '\n');
}
delay(200);
}Limits and alternatives
the ADC's sample capacitor holds the previous channel's charge. With high-impedance sources (above about 10 kΩ), add a short delay and discard the first reading, or buffer the signal.
a signal above VCC or below GND can damage the chip or leak into other channels. Use a voltage divider first.
it is a signal switch, not a power switch; do not drive motors or LEDs through it.
Try it: ADC resolution calculator
Change the values and the diagram and results update as you type.
Common mistakes to avoid
- Leaving EN floating or high.
- Feeding signals outside the supply range.
- Reading straight after switching channels without settling.
- Running the mux at 5 V into a 3.3 V ADC.
- Switching load current through it.
Frequently asked questions
How many sensors can I read with one analog pin?
16 with a CD74HC4067, or more by chaining several multiplexers on separate enable lines.
Can a multiplexer read buttons?
Yes. It works for digital signals too; add pull-ups on the button side.
CD4051 or 74HC4051?
The 74HC4051 is faster and has lower on-resistance at 5 V; the CD4051 tolerates higher supply voltages.
Why are my readings mixed between channels?
Not enough settling time or high-impedance sources. Add a delay and discard the first reading.
Does it work with ESP32?
Yes, powered from 3.3 V.
Parts for this guide
- ₹53View
Calculators
Terms in this guide
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

