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 (3)

  • 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

Leave a Reply

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