Parts

74HC4051 8-channel multiplexer

Eight analog switches with one common pin, in a 16-pin DIP: three address lines pick which channel reaches Z.

This part has a page of its own, with a note on using it and a circuit to try: the part page.

Aliases: 74HC4051, CD74HC4051, CD4051, 8-channel analog mux. One analog pin reads eight knobs or sensors, or one pin drives eight outputs in turn, because each switch passes current in either direction. It is the smaller cousin of the CD74HC4067.

Pins

Pin What it does
Y0 to Y7 The eight channels.
Z The common pin, to an analog input (or a PWM output).
S0, S1, S2 The channel address, S0 the least significant bit.
E Enable, active low. High opens every switch. Tie it to GND if unused.
VEE The negative analog supply. On an Arduino, tie it to GND.
VCC, GND Supply, 2 to 6 V.

Reading eight knobs on an Arduino

const int S0 = 2, S1 = 3, S2 = 4;

int readChannel(int ch) {
  digitalWrite(S0, ch & 1);
  digitalWrite(S1, (ch >> 1) & 1);
  digitalWrite(S2, (ch >> 2) & 1);
  return analogRead(A0);   // Z is on A0
}

Properties

model: 74HC4051 (the default) or CD4051B, the same multiplexer in the 4000 series, pin for pin (TI's CD4051B data sheet names the pins CH0 to CH7, COM, INH and A B C). The CD4051B runs from 3 V to 18 V, and its switches have a much higher on-resistance: 470 ohms typical at 5 V, 180 ohms at 10 V and 125 ohms at 15 V, against the 74HC4051's 70 ohms. The 74HC4052, 74HC4053 and 74HC4066 have the same setting.

What the model gets right

From the Nexperia 74HC4051 and TI CD74HC4051 datasheets: E low joins the addressed channel to Z through the switch's on-resistance, both ways round, and leaves the others open; E high opens them all. The on-resistance is about 70 ohm at 4.5 V and more at lower supplies, so a load on Z divides against it. The address and enable are CMOS inputs read against half the supply; an address that is not a clean level opens every switch.

What it does not model

The switching time, break-before-make, charge injection, leakage, the on-resistance's change with the signal voltage, and signals below ground: VEE is not read, as if it were tied to GND.

Common mistakes

Leaving E or VEE unconnected. Reading Z straight after changing the address with a large source resistance: give the input a moment to settle.

The tutorial Arduino CD74HC4067 multiplexer covers this chip too, with Mux eight as its second circuit.