Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.

CD74HC4067 Arduino: 16-Channel Multiplexer Guide

Expanding analog and digital I/O capabilities represents a constant challenge in Arduino projects. As a PCB engineer who’s integrated multiplexers in production systems, I’ve found the CD74HC4067 Arduino combination provides the most cost-effective solution for projects requiring multiple sensor inputs or output channels. This comprehensive guide explores CD74HC4067 functionality, wiring configurations, programming techniques, and practical applications enabling you to multiply your Arduino’s I/O capacity sixteen-fold using just five pins.

Understanding the CD74HC4067 Multiplexer

The CD74HC4067 is a 16-channel analog/digital multiplexer-demultiplexer manufactured by Texas Instruments. This CMOS logic chip functions as an electronically controlled switch routing one common signal (SIG pin) to any of 16 individual channels based on four binary select inputs. The bidirectional nature enables both multiplexing (many-to-one) and demultiplexing (one-to-many) applications.

From a circuit design perspective, the CD74HC4067 operates as an array of analog switches controlled digitally. Unlike digital multiplexers handling only HIGH/LOW states, analog multiplexers switch continuous voltage signals making them suitable for reading potentiometers, analog sensors, and other variable-voltage sources. The same chip handles digital signals equally well, enabling use with buttons, switches, and digital communication protocols.

The chip’s internal architecture uses MOSFET switches providing bidirectional signal flow with low on-resistance (typically 70Ω at 4.5V supply). This low resistance ensures minimal signal degradation during switching. The fast switching time (approximately 80ns) supports rapid channel scanning essential for responsive multi-sensor systems.

CD74HC4067 Pinout and Specifications

Understanding pin functions ensures proper connection and operation:

Pin NameFunctionConnection
C0-C1516 Channel PinsConnect sensors/devices here
SIG (COM)Common Signal PinArduino analog or digital pin
S0-S3Channel Select PinsArduino digital outputs
ENEnable (Active LOW)Ground to enable, HIGH to disable
VCCPower Supply5V from Arduino
GNDGroundArduino ground

Key Electrical Specifications

Supply Voltage Range: 2V to 6V (typically 5V with Arduino)

Maximum Continuous Current: 25mA per channel. This matches Arduino pin current capacity making the combination well-suited for direct sensor interfacing.

On-Resistance: 70Ω typical at VCC=4.5V. Low enough for most analog applications but may require consideration for precision measurements.

Switching Time: 80ns typical. Fast enough for most Arduino applications including audio frequency signals up to several kHz.

Crosstalk Between Channels: -70dB at 10kHz. Excellent isolation preventing adjacent channel interference during rapid switching.

Analog Signal Range: 0V to VCC. Signals must remain within power supply rails preventing damage to internal switches.

These specifications make the CD74HC4067 Arduino interface ideal for expanding analog input capacity, multiplexing digital sensors, or controlling multiple output devices efficiently.

Channel Selection Logic and Addressing

The four select pins (S0-S3) use binary encoding to select one of 16 channels:

Binary Channel Selection Table

ChannelS3S2S1S0Binary Value
000000b0000
100010b0001
200100b0010
300110b0011
810000b1000
1511110b1111

The relationship follows standard binary counting where S0 represents the least significant bit (LSB) and S3 the most significant bit (MSB). This encoding allows simple bitwise operations in code selecting any channel efficiently.

Understanding this addressing scheme enables manual channel selection or library-free implementations. Many Arduino libraries abstract this complexity, but knowing the underlying logic helps troubleshooting and optimization.

Wiring CD74HC4067 to Arduino

Proper connections ensure reliable operation. Here’s the standard configuration:

Basic Arduino Connection

Power Connections:

  • CD74HC4067 VCC → Arduino 5V
  • CD74HC4067 GND → Arduino GND
  • CD74HC4067 EN → Arduino GND (enable always-on)

Control Pins:

  • CD74HC4067 S0 → Arduino Digital Pin 8
  • CD74HC4067 S1 → Arduino Digital Pin 9
  • CD74HC4067 S2 → Arduino Digital Pin 10
  • CD74HC4067 S3 → Arduino Digital Pin 11

Signal Pin:

  • CD74HC4067 SIG → Arduino Analog Pin A0 (for analog reading) or any digital pin

Sensor Connections:

  • Connect up to 16 sensors/devices to C0-C15 pins
  • Sensor grounds connect to common Arduino ground

This configuration uses five Arduino pins (four digital outputs plus one analog/digital input) to access 16 channels. The tradeoff favors most applications where pin count matters more than the slight overhead of sequential scanning.

Alternative EN Pin Control

Instead of permanently grounding EN, connect it to an Arduino digital pin:

  • CD74HC4067 EN → Arduino Digital Pin 7

This connection enables powering down the multiplexer when not in use, reducing power consumption in battery-operated projects. Setting the EN pin HIGH disables all channels preventing any signal flow. This feature proves useful in power-sensitive applications or when switching between multiple multiplexers.

Programming CD74HC4067 with Arduino

Several approaches exist for CD74HC4067 Arduino control ranging from manual bit manipulation to full-featured libraries:

Manual Channel Selection Function

const int S0 = 8;

const int S1 = 9;

const int S2 = 10;

const int S3 = 11;

const int SIG = A0;

void setup() {

  pinMode(S0, OUTPUT);

  pinMode(S1, OUTPUT);

  pinMode(S2, OUTPUT);

  pinMode(S3, OUTPUT);

  Serial.begin(9600);

}

void selectChannel(byte channel) {

  digitalWrite(S0, bitRead(channel, 0));

  digitalWrite(S1, bitRead(channel, 1));

  digitalWrite(S2, bitRead(channel, 2));

  digitalWrite(S3, bitRead(channel, 3));

  delayMicroseconds(10); // Allow switching time

}

void loop() {

  for(int i = 0; i < 16; i++) {

    selectChannel(i);

    int value = analogRead(SIG);

    Serial.print(“Channel “);

    Serial.print(i);

    Serial.print(“: “);

    Serial.println(value);

    delay(100);

  }

}

This code demonstrates fundamental multiplexer control. The bitRead() function extracts individual bits from the channel number setting select pins appropriately. The 10μs delay ensures switching completes before reading, preventing crosstalk between channels.

Using Arduino Libraries

Several libraries simplify CD74HC4067 Arduino interfacing:

light_CD74HC4067: Lightweight library using minimal memory. Install from Arduino Library Manager by searching “light_CD74HC4067”. This library handles channel selection with simple mux.channel(n) commands.

HC4067: More feature-rich library supporting enable pin control and multiple multiplexer instances. Available through Library Manager or GitHub (RobTillaart/HC4067).

Libraries abstract low-level bit manipulation providing cleaner code and reducing development time. For production projects, I typically start with libraries then optimize critical sections using direct manipulation if necessary.

Reading Multiple Analog Sensors

The primary CD74HC4067 Arduino application involves reading multiple analog sensors with limited analog pins:

Practical Sensor Reading Example

#include <light_CD74HC4067.h>

CD74HC4067 mux(8, 9, 10, 11); // S0, S1, S2, S3

const int SIGNAL_PIN = A0;

void setup() {

  Serial.begin(9600);

  pinMode(SIGNAL_PIN, INPUT);

}

void loop() {

  float temperatures[4];

  // Read four temperature sensors on channels 0-3

  for(int i = 0; i < 4; i++) {

    mux.channel(i);

    delayMicroseconds(100); // Settling time

    int rawValue = analogRead(SIGNAL_PIN);

    temperatures[i] = (rawValue * 5.0 / 1023.0 – 0.5) * 100.0; // TMP36 conversion

  }

  // Display readings

  for(int i = 0; i < 4; i++) {

    Serial.print(“Sensor “);

    Serial.print(i);

    Serial.print(“: “);

    Serial.print(temperatures[i]);

    Serial.println(“°C”);

  }

  delay(1000);

}

This example reads four TMP36 temperature sensors connected to channels 0-3. The settling delay after channel switching ensures the analog input stabilizes before reading. This delay becomes critical when switching between sensors with significantly different voltage levels.

Testing reveals that 100μs settling time works reliably for most analog sensors. Faster sensors like photodiodes may require less; slower sensors like thermistors might need more. Adjust based on your specific sensor characteristics and required accuracy.

Digital Input Applications

CD74HC4067 Arduino configurations excel at reading multiple buttons or switches:

Button Matrix Reading

const int S0 = 8, S1 = 9, S2 = 10, S3 = 11;

const int SIG = 2; // Digital input with internal pull-up

byte lastButtonState[16] = {HIGH};

void setup() {

  pinMode(S0, OUTPUT);

  pinMode(S1, OUTPUT);

  pinMode(S2, OUTPUT);

  pinMode(S3, OUTPUT);

  pinMode(SIG, INPUT_PULLUP);

  Serial.begin(9600);

}

void selectChannel(byte channel) {

  digitalWrite(S0, channel & 1);

  digitalWrite(S1, (channel >> 1) & 1);

  digitalWrite(S2, (channel >> 2) & 1);

  digitalWrite(S3, (channel >> 3) & 1);

}

void loop() {

  for(int ch = 0; ch < 16; ch++) {

    selectChannel(ch);

    delayMicroseconds(5);

    byte currentState = digitalRead(SIG);

    if(currentState != lastButtonState[ch]) {

      if(currentState == LOW) {

        Serial.print(“Button “);

        Serial.print(ch);

        Serial.println(” pressed”);

      }

      lastButtonState[ch] = currentState;

      delay(50); // Simple debounce

    }

  }

}

This implementation scans 16 buttons detecting state changes. The internal pull-up resistor on the signal pin eliminates need for external resistors. Buttons connect between channel pins and ground providing reliable switch detection.

The debounce delay prevents multiple triggers from mechanical switch bounce. More sophisticated projects might implement per-button timers allowing simultaneous button presses without missing fast button events.

Output Control and Demultiplexing

The CD74HC4067 Arduino combination works bidirectionally enabling output applications:

Controlling Multiple LEDs

const int S0 = 8, S1 = 9, S2 = 10, S3 = 11;

const int SIG = 5; // Digital output pin

void setup() {

  pinMode(S0, OUTPUT);

  pinMode(S1, OUTPUT);

  pinMode(S2, OUTPUT);

  pinMode(S3, OUTPUT);

  pinMode(SIG, OUTPUT);

}

void selectChannel(byte channel) {

  digitalWrite(S0, channel & 1);

  digitalWrite(S1, (channel >> 1) & 1);

  digitalWrite(S2, (channel >> 2) & 1);

  digitalWrite(S3, (channel >> 3) & 1);

}

void loop() {

  // Knight Rider style scanning LED

  for(int i = 0; i < 16; i++) {

    selectChannel(i);

    digitalWrite(SIG, HIGH);

    delay(50);

    digitalWrite(SIG, LOW);

  }

  for(int i = 14; i > 0; i–) {

    selectChannel(i);

    digitalWrite(SIG, HIGH);

    delay(50);

    digitalWrite(SIG, LOW);

  }

}

This example creates scanning LED effect controlling 16 LEDs from single digital pin. Each LED connects between its channel pin and ground with appropriate current-limiting resistor (typically 220Ω-470Ω for standard LEDs).

Note that only one LED illuminates at any time due to multiplexer nature. For applications requiring multiple simultaneous outputs, use PWM with rapid scanning creating persistence-of-vision effect. Scan rates above 50Hz appear as continuous illumination to human vision.

Cascading Multiple CD74HC4067 Modules

Projects requiring more than 16 channels cascade multiple multiplexers:

Dual Multiplexer Configuration

Method 1: Separate Signal Pins

  • Multiplexer 1 SIG → Arduino A0
  • Multiplexer 2 SIG → Arduino A1
  • Share S0-S3 connections between both multiplexers
  • Result: 32 channels using 6 Arduino pins

Method 2: EN Pin Control

  • Share S0-S3 and SIG connections
  • Multiplexer 1 EN → Arduino Pin 7
  • Multiplexer 2 EN → Arduino Pin 6
  • Result: 32 channels using 6 Arduino pins

The EN pin method saves one analog pin but requires software coordination ensuring only one multiplexer enables at a time. The separate signal pin approach provides simpler programming and faster switching between multiplexers.

In production designs combining more than 32 channels, I recommend using a shift register (like 74HC595) driving the select pins. This reduces Arduino pin requirements further, enabling control of 64+ channels using only 3-4 Arduino pins total.

Crosstalk and Signal Integrity

Multiplexer performance depends on proper signal handling:

Minimizing Crosstalk

Channel-to-Channel Crosstalk: Adjacent unselected channels may exhibit small signal coupling. The CD74HC4067 specification guarantees -70dB isolation at 10kHz, but practical implementations sometimes show degraded performance from poor layout.

Prevention Strategies:

  • Add 10-100μs settling delay after channel selection
  • Include small RC filter (100Ω + 0.1μF) on signal pin for noise immunity
  • Keep channel wiring short (under 10cm) preventing capacitive coupling
  • Separate analog and digital signals on different multiplexers when possible

Grounding Best Practices

Proper grounding dramatically improves measurement accuracy:

Star Grounding: Connect all sensor grounds to single point near multiplexer, then route single wire to Arduino ground. This prevents ground current loops creating voltage differences between sensors.

Ground Plane: On PCBs, solid ground plane under multiplexer reduces noise pickup. Through-hole vias connect ground pins directly to plane minimizing inductance.

Shielded Cable: For long sensor wires (>30cm), use shielded cable with shield grounded at multiplexer end only. This prevents differential noise without creating ground loops.

Common Problems and Solutions

Years of CD74HC4067 Arduino implementations reveal frequent issues:

Unstable or Incorrect Readings

Symptom: Analog readings fluctuate wildly or show values from wrong channels.

Causes: Insufficient settling time after channel switching, missing ground connections, floating inputs on unused channels.

Solutions: Increase delay after selectChannel() to 100μs or more. Verify all grounds connect solidly to common point. Connect 10kΩ pull-down resistors to unused analog input channels preventing floating voltages.

Missing or Intermittent Channel Selection

Symptom: Some channels never activate or work inconsistently.

Causes: Poor connections on select pins, incorrect pin mapping in code, supply voltage issues.

Solutions: Verify S0-S3 connections with multimeter measuring voltage at multiplexer pins during channel selection. Confirm pin numbers in code match physical wiring. Measure VCC at multiplexer ensuring 5V ±0.2V.

Channels Stay Always-On or Always-Off

Symptom: All channels output HIGH continuously or no channels work.

Causes: EN pin incorrectly connected, signal pin not properly configured.

Solutions: For always-on, verify EN pin connects to GND (not floating or connected to VCC). For always-off, check signal pin configured as INPUT for reading or OUTPUT for controlling. Measure voltage on EN pin; it should be 0V for normal operation.

Practical Applications

Real-world CD74HC4067 Arduino implementations demonstrate versatility:

Multi-Zone Environmental Monitoring

Monitor temperature and humidity in 8 rooms using DHT22 sensors:

  • 8× DHT22 sensors connected to channels 0-7
  • Sequential scanning with 2-second intervals per sensor
  • Data logging to SD card with timestamps
  • Alert system for out-of-range conditions

This application demonstrates CD74HC4067’s value in distributed sensing where running 8 separate sensor wires to Arduino would be impractical.

MIDI Controller with 16 Potentiometers

Professional music controller using:

  • 16× 10kΩ potentiometers for parameter control
  • Rapid scanning (200Hz) for responsive feel
  • MIDI output converting analog values to MIDI CC messages
  • Channel pressure and velocity sensitivity

The fast switching time enables real-time control feeling like direct connections despite multiplexing.

Home Automation Switch Panel

Central control panel managing:

  • 16× momentary buttons for device control
  • LED feedback showing device states
  • Bidirectional operation: read buttons, control status LEDs
  • Integration with home automation system via serial communication

Essential Resources

Resource TypeDescriptionAccess
TI CD74HC4067 DatasheetOfficial specifications and characteristicsTI Website PDF
SparkFun Breakout BoardPre-wired module with labeled pinsSparkFun Electronics
light_CD74HC4067 LibraryLightweight Arduino libraryArduino Library Manager
HC4067 LibraryFeature-rich alternative libraryGitHub RobTillaart
Multiplexer CalculatorOnline tool for channel calculationsVarious web tools

Downloadable Resources:

Example Sketches Collection: Tested code examples for analog input, digital input, output control, and cascaded configurations ready for modification.

Fritzing Parts Library: CD74HC4067 component for circuit diagrams and breadboard layouts simplifying documentation.

PCB Footprint Files: Eagle and KiCad footprints for both DIP and SSOP packages enabling custom PCB designs.

Frequently Asked Questions

Q: Can I mix analog and digital signals on the same CD74HC4067?

A: Yes, but not simultaneously on the same channel. The multiplexer passes any signal type within its voltage range. However, for projects mixing both signal types, use separate multiplexers for analog and digital to prevent crosstalk and simplify programming. The minimal cost difference ($2-3 per multiplexer) justifies the improved signal integrity and cleaner code organization.

Q: How fast can I scan through all 16 channels?

A: Theoretically, with 80ns switching time, extremely fast scanning is possible. Practically, Arduino analogRead() takes approximately 100μs, limiting total scan rate to about 6.25kHz for 16 channels (160μs per complete cycle). For most applications, 100-500Hz scanning provides adequate response. High-speed applications requiring faster sampling should consider dedicated ADC ICs or reducing active channel count.

Q: Do I need resistors when connecting sensors to the CD74HC4067?

A: It depends on the sensor. Voltage-output sensors (like TMP36) connect directly without resistors. Resistive sensors (photoresistors, thermistors) need pull-up or pull-down resistors forming voltage dividers. Current-output sensors require load resistors converting current to voltage. Always verify sensor specifications and required interface circuitry. The multiplexer itself doesn’t require series resistors unless limiting current for protection.

Q: Can I use CD74HC4067 for I2C or SPI signals?

A: Not recommended for I2C due to bidirectional requirements and timing sensitivity. I2C needs dedicated bidirectional level shifters or buffers. For SPI, you can multiplex slave select (CS) lines enabling multiple SPI devices sharing MOSI/MISO/SCK, but dedicated CS pins work better for reliable high-speed communication. Use the multiplexer primarily for analog signals and simple digital I/O rather than complex communication protocols.

Q: Why do my readings jump when switching between channels with very different voltages?

A: Multiplexer internal capacitance and Arduino ADC sample-and-hold capacitor retain charge from the previous channel. When switching to a channel with significantly different voltage, this residual charge causes initial reading error. Increase settling delay to 200-500μs after channel selection for large voltage differences. Alternatively, perform two consecutive reads per channel discarding the first (contaminated) reading, using only the second stabilized value.

Maximizing CD74HC4067 Arduino Integration

The CD74HC4067 Arduino combination provides powerful I/O expansion for projects constrained by limited pin count. Understanding multiplexer operation, proper wiring techniques, and signal integrity considerations ensures reliable implementations whether prototyping on breadboards or designing production PCBs.

Start with simple single-purpose applications like reading multiple potentiometers or buttons before advancing to complex multi-sensor systems. This progressive approach builds understanding while minimizing troubleshooting complexity. Test each channel independently verifying correct operation before implementing full scanning routines.

For production designs, consider PCB layout carefully. Route select pins and ground traces with adequate width preventing voltage drops. Position decoupling capacitors (0.1μF) immediately adjacent to VCC/GND pins. Keep analog signal traces short and separated from digital switching signals minimizing noise coupling.

The modest $2-5 investment in CD74HC4067 modules or bare ICs enables Arduino projects that would otherwise require expensive boards with more native I/O. This cost-effective expansion maintains Arduino’s simplicity while unlocking complex multi-sensor and multi-actuator applications previously impractical on single boards.

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Sales & After-Sales Service

Contact & Quotation

  • Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.

  • Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.

Drag & Drop Files, Choose Files to Upload You can upload up to 3 files.

Notes:
For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.