← All parts

CD4051 8-ch Mux

CD4051B

Texas Instrumentsic logic

The CD4051B is a CMOS single 8-channel analog multiplexer/demultiplexer with logic-level conversion. Three address inputs and an inhibit select one of eight bidirectional channels to a common line.

In stock

Specifications

4
Operating Voltage
3 to 20 V
On Resistance
125 ohm
Operating Temperature Range
-55 to 125 C
Package Types
CDIP, PDIP, SOIC, SOP, TSSOP

Pinout

16
PinNameFunctionsNotes
1CH 4 IN/OUT
GPIO
Channel 4 in/out
2CH 6 IN/OUT
GPIO
Channel 6 in/out
3COM OUT/IN
GPIO
Common out/in
4CH 7 IN/OUT
GPIO
Channel 7 in/out
5CH 5 IN/OUT
GPIO
Channel 5 in/out
6INH
GPIO
Inhibit input, disables all channels
7VEE
POWER
Negative power input
8VSS
POWERGND
Ground
9C
GPIO
Channel select C
10B
GPIO
Channel select B
11A
GPIO
Channel select A
12CH 3 IN/OUT
GPIO
Channel 3 in/out
13CH 0 IN/OUT
GPIO
Channel 0 in/out
14CH 1 IN/OUT
GPIO
Channel 1 in/out
15CH 2 IN/OUT
GPIO
Channel 2 in/out
16VDD
POWER
Positive power input

Interactive pinout

Highlight:
CD4051B

Click a pin to copy its name · tap a tag above to spotlight a bus.

Starter code

Community starter examples — minimal, unofficial, and provided to get you wiring fast. Verify against the manufacturer datasheet before relying on them.

Arduino (C++)

arduino
// CD4051 8-channel analog mux/demux — community starter example
// Select a channel with A/B/C, then read it through the common pin.
#if defined(ESP32)
  #define A_PIN 25
  #define B_PIN 26
  #define C_PIN 27
  #define COM_ADC 34   // common -> an ADC input
#else
  #define A_PIN 2
  #define B_PIN 3
  #define C_PIN 4
  #define COM_ADC A0
#endif

void selectChannel(uint8_t ch) {     // 0..7
  digitalWrite(A_PIN, ch & 1);
  digitalWrite(B_PIN, (ch >> 1) & 1);
  digitalWrite(C_PIN, (ch >> 2) & 1);
}

void setup() {
  Serial.begin(115200);
  pinMode(A_PIN, OUTPUT); pinMode(B_PIN, OUTPUT); pinMode(C_PIN, OUTPUT);
}

void loop() {
  for (uint8_t ch = 0; ch < 8; ch++) {
    selectChannel(ch);
    delayMicroseconds(50);
    Serial.print(analogRead(COM_ADC)); Serial.print(' ');
  }
  Serial.println();
  delay(500);
}

MicroPython

python
# CD4051 8-channel analog mux (ESP32) — community starter example
from machine import Pin, ADC
import time

a = Pin(25, Pin.OUT); b = Pin(26, Pin.OUT); c = Pin(27, Pin.OUT)
com = ADC(Pin(34)); com.atten(ADC.ATTN_11DB)   # common -> ADC

def select(ch):
    a.value(ch & 1); b.value((ch >> 1) & 1); c.value((ch >> 2) & 1)

while True:
    vals = []
    for ch in range(8):
        select(ch); time.sleep_us(50); vals.append(com.read())
    print(vals)
    time.sleep(0.5)

Wiring

PinArduino Uno R3ESP32 DevKitC (WROOM-32)Notes
VDD+5V3V3Analog signals must stay within VEE..VDD
VSSGNDGND
VEEGNDGNDTie to GND for single-supply use
AD2GPIO25Channel select bit 0
BD3GPIO26Channel select bit 1
CD4GPIO27Channel select bit 2
COMA0GPIO34Common -> an ADC input
INHGNDGNDTie LOW to enable the mux

Typical uses

  • Reading 8 analog sensors through 1 ADC pin
  • Routing one signal to 8 outputs (demux)

Related parts

6