Part

CD74HC4067 analog multiplexer

Sixteen channels to one pin through analog switches: four address lines pick which one.

See every part
  • 24 pins
  • In 1 project
  • In 1 lesson
Drawn live by the editor's own code, at the size you see it.
CD74HC4067 analog multiplexer as drawn in the Mokxi simulator
At a glance

The CD74HC4067 analog multiplexer in brief

What it is, and where it sits on the bench.

The CD74HC4067 is a 16 channel analog multiplexer: sixteen analog switches with one common pin, where four address lines pick which channel reaches COM. The pins are I0 to I15, the sixteen channels, COM, the common pin, called SIG on some boards, S0 to S3, the channel address with S0 the least significant bit, EN, enable, active low, which opens every switch when high, and VCC and GND, 2 to 6 V. Each switch passes current in either direction. One analog pin reads sixteen sensors, or one pin drives sixteen outputs in turn. While it runs, the marker beside the channel joined to COM lights. It is the bigger cousin of the 74HC4051, which has eight channels.

Family
Logic
Pins
24
Pins

24 pins

Named as the editor names them, so a wire lands where you expect it.

Pin
What it does
I15
I14
I13
I12
I11
I10
I9
I8
I7
I6
I5
I4
I3
I2
I1
I0
COM
The common pin (SIG on some boards).
S3
S2
S1
S0
EN
Enable, active low: tie it to ground, or high to open every switch.
VCC
Supply, 2 to 6 V.
GND
Ground.
How to use it

How to read sixteen sensors on one pin with a CD74HC4067

COM goes to A0. The four address pins S0 to S3 go to Uno pins 2 to 5. EN is tied to GND so the switches are on, VCC goes to 5 V and GND to the Uno’s ground. The three knobs’ wipers go to channels I0, I5 and I15.

The sketch writes the channel number onto the four address pins, bit 0 to S0, waits 50 microseconds for the switch to settle, and reads A0. It reads channels 0, 5 and 15 and prints them. Turn each knob and its channel follows. Sixteen channels use four address pins, where the 74HC4051’s eight need three.

Part pin
Board pin
COM
A0
S0, S1, S2, S3
Pins 2, 3, 4, 5
I0, I5, I15
The three knobs’ wipers
EN, GND
Ground
VCC
5 V
Mux knobslive0.000 s 0.00x
Click to open it in the editor
This is the simulator itself, running here. Click anything to open it in the editor.
Pick a channel, then read
const uint8_t ADDRESS[4] = {2, 3, 4, 5};   // S0 to S3
const uint8_t CHANNELS[3] = {0, 5, 15};

int readChannel(uint8_t channel) {
  for (uint8_t bit = 0; bit < 4; bit++) {
    digitalWrite(ADDRESS[bit], (channel >> bit) & 1 ? HIGH : LOW);
  }
  delayMicroseconds(50);                    // let the switch settle
  return analogRead(A0);                    // COM on A0
}

void setup() {
  Serial.begin(9600);
  for (uint8_t bit = 0; bit < 4; bit++) pinMode(ADDRESS[bit], OUTPUT);
}

void loop() {
  for (uint8_t i = 0; i < 3; i++) {
    Serial.print("ch");
    Serial.print(CHANNELS[i]);
    Serial.print(" ");
    Serial.println(readChannel(CHANNELS[i]));
  }
  delay(300);
}
Common errors

Common CD74HC4067 analog multiplexer errors and fixes

What goes wrong
The fix
Every channel reads nothing.
EN is active low. Tie it to ground, since high opens every switch.
A channel reads the previous one.
Wait a short time after setting the address before analogRead(), as the sketch does with 50 microseconds.
The wrong channel is read.
S0 is the least significant bit. Check S0 to S3 go to pins 2 to 5 in order.
Questions

Questions and answers

How many channels does the CD74HC4067 have?

Sixteen, I0 to I15, picked by the four address pins S0 to S3.

What is the common pin called?

COM, and SIG on some boards.

What is the difference from the 74HC4051?

The 74HC4051 has eight channels and three address pins. The CD74HC4067 has sixteen and four.

How it is modeled

What is true about the CD74HC4067 analog multiplexer, here

In its help article’s own words: what the simulation gets right, and where it stops.

Modeled

From the TI datasheet:

It is a switch, not a buffer. The chosen channel is joined to COM through the on-resistance, both ways, so the signal is divided by whatever loads it, as on the bench.

The on-resistance: 70 ohm typical from 4.5 V up, 100 ohm from 3 V and 160 ohm below.

Every other channel is open, and EN high opens them all. An address line that is not a clean logic level opens every switch too.

Not modeled

The switching time, break-before-make, charge injection, leakage, the on-resistance's change with the signal voltage, and signals past the supply rails, which a real one clamps.

From CD74HC4067 16-channel multiplexer, in full.

Projects

See the CD74HC4067 analog multiplexer in a project

One built-in project uses it. It opens in the editor, already wired.

Lessons

Where it turns up in a lesson

One lesson places it in its own circuit.

Boards

The boards it is shown on

This board has a built-in project with the CD74HC4067 analog multiplexer in it.

Libraries

Arduino libraries for the CD74HC4067 analog multiplexer

Built in, so the sketch compiles with nothing to install. Each page has the calls, the wiring and an example to run.

Wire up the CD74HC4067 analog multiplexer

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.