Contents

Interfacing CD74HC4067 16-Channel Multiplexer with Arduino

If you’re looking to interface the CD74HC4067 16-Channel Multiplexer with Arduino, you’ve come to the right place. In this guide, we’ll walk you through the features of the CD74HC4067 module, provide a pinout diagram, and explain the steps to connect it to an Arduino. By following this guide, you’ll be able to effectively use the CD74HC4067 multiplexer in your analog input projects.

CD74HC4067 16-Channel Multiplexer Features

The CD74HC4067 16-Channel analog-digital multiplexer module can be used when there are many analog inputs in a circuit. In this case, one of these inputs needs to be selected and processed each time. This multiplexer can be used to select from 16 analog inputs. There are four S0-3 pins, which by giving appropriate values, one of the analog inputs is set as the output in the SIG pin.

CD74HC4067 16-Channel Multiplexer Pinout

This module has 24 pins:

  • VCC: Module power supply – 5V
  • GND: Ground
  • EN: Enable pin (Active Low)
  • S0-3: Selecting one of 16 analog input pins as the final output signal
  • C0-15: Analog inputs
  • SIG: Output signal

You can see the pinout of this module in the image below.

Required Materials

Hardware Components

Arduino UNO R3 × 1
CD74HC4067 16-Channel Analog Digital Multiplexer Module × 1
Male to Female jumper wire × 1

Software Apps

Arduino IDE

Interfacing CD74HC4067 16-Channel Multiplexer with Arduino

Now, let’s get into the step-by-step process of interfacing the CD74HC4067 multiplexer with an Arduino.

Step 1: Circuit

The following circuit shows how you should connect Arduino to CD74HC4067 module. Connect wires accordingly.

Then you can connect the desired analog inputs to pins C0-15.

To test the performance of the circuit and code, you can use a voltage divider according to the following circuit.

Step 2: Code

connect the voltage divider circuit as shown above. Upload the following code to Arduino. After uploading the code, open the Serial Monitor.

 /* 
Modified on Nov 28, 2020
Modified by MehranMaleki from Arduino Examples
Home
*/ //Mux control pins int s0 = 8; int s1 = 9; int s2 = 10; int s3 = 11; //Mux in "SIG" pin int SIG_pin = 0; void setup(){ pinMode(s0, OUTPUT); pinMode(s1, OUTPUT); pinMode(s2, OUTPUT); pinMode(s3, OUTPUT); digitalWrite(s0, LOW); digitalWrite(s1, LOW); digitalWrite(s2, LOW); digitalWrite(s3, LOW); Serial.begin(9600); } void loop(){ //Loop through and read all 16 values for(int i = 0; i < 16; i ++){ Serial.print("Value at channel "); Serial.print(i); Serial.print("is : "); Serial.println(readMux(i)); delay(1000); } } float readMux(int channel){ int controlPin[] = {s0, s1, s2, s3}; int muxChannel[16][4]={ {0,0,0,0}, //channel 0 {1,0,0,0}, //channel 1 {0,1,0,0}, //channel 2 {1,1,0,0}, //channel 3 {0,0,1,0}, //channel 4 {1,0,1,0}, //channel 5 {0,1,1,0}, //channel 6 {1,1,1,0}, //channel 7 {0,0,0,1}, //channel 8 {1,0,0,1}, //channel 9 {0,1,0,1}, //channel 10 {1,1,0,1}, //channel 11 {0,0,1,1}, //channel 12 {1,0,1,1}, //channel 13 {0,1,1,1}, //channel 14 {1,1,1,1} //channel 15 }; //loop through the 4 sig for(int i = 0; i < 4; i ++){ digitalWrite(controlPin[i], muxChannel[channel][i]); } //read the value at the SIG pin int val = analogRead(SIG_pin); //return the value float voltage = (val * 5.0) / 1024.0; return voltage; }

In the above code, by giving the appropriate values to pins S0-3 per second, we select pins C0-15, respectively, and the SIG pin voltage which should be equal to selected pin, appears on Serial Monitor.

The output is as follows.

Liked What You See?​
Get Updates And Learn From The Best​

Comments (8)

  • Sunit Raut Reply

    For code, I would suggest using the light_CD74HC4067 library.
    The code that you have shown in this tutorial is quite memory-consuming.
    light_CD74HC4067 will save much more memory and is easy to use. This library can be downloaded through Arduino IDE.

    October 6, 2022 at 4:21 am
  • BV Reply

    If I need to make it 32 (basically two of these ICs), does that mean 10 pins from the Arduino? I was trying to use the ATMega2560 and add 32 more pins to it

    August 9, 2023 at 6:17 pm
    • Mohammad Damirchi Reply

      Hi BV,
      To use 32 ADC pins, u need 2 ADC pins from your Arduino, like A0 and A1, and 8 digital pins for the Selector pin of CD74HC4067.

      August 13, 2023 at 9:03 am
      • adrian brooks Reply

        You could probably use a NO/NC relay and connect to the _EN pin on each of the two multiplexer chips or two digital outputs to select each chip and the same address pins for both chips or there are probably chips that you can address using SPI or I2C

        April 19, 2024 at 9:15 pm
        • Mohammad Damirchi Reply

          Hello Adrian,
          That’s correct! You can utilize the EN pin (there’s no need for a relay; simply connect both EN pins to the Arduino or use a transistor to invert the output).
          However, it’s important to note that this chip doesn’t support SPI or I2C and operates solely with Parallel communication.
          In such conditions, you can establish Parallel wiring between these two ICs. (only 4 line of data)

          April 20, 2024 at 8:11 am
  • Saikat Banerjee Reply

    How will it work without pulling the EN pin to LOW (Ground) ? The EN pin is active LOW

    June 20, 2024 at 7:05 am
    • Mohammad Damirchi Reply

      Hello,
      The Enable pin operates on an Active-LOW logic.
      Setting the EN pin to HIGH disables the multiplexer output.

      June 22, 2024 at 7:53 am
  • A Human Who Writes Things Because They Care About The Things. Reply

    I’m really sad that the makersphere is getting filled with this AI garbage.

    And then I have to “prove” I’m not a robot to post this.

    August 10, 2024 at 4:55 pm

Leave a Reply

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