Professional Documents
Culture Documents
Home
Tronixlabs
Kit Reviews
Reviews
About
Contact Us
Introduction
Now and again theres a need to expand the I/O capabilities of your chosen micorocontroller, and instead
of upgrading you can often use external parts to help solve the problem. One example of this is the
74HC4067 16-channel analog multiplexer demultiplexer. Thats a mouthful however in simple form its
an IC that can direct a flow of current in either direction from one pin to any one of sixteen pins. Another
way to think abou it is that you can consider the 74HC4067 to be a digital replacement to those rotary
switches that allow you to select one of sixteen positions.
Dont let that put you off, its just what we had in stock at the time. The part itself is available in
1 de 14 24/11/2016 0:53
Tutorial 74HC4067 16-Channel Analog Multiplexer Demultiplexer http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-an...
At this point you should download the data sheet, as we refer to it through the course of the article. The
first thing to note is that the 74HC4067 can operate on voltages between 2 and 6V DC, which allows use
with 3.3V and 5V microcontrollers and boards such as Arduino and Raspberry Pi. If for some reason you
have the 74HCT4067 it can only work on 4.5~5.5V DC. Next consider the pinout diagram from the
data sheet:
Next pin one. This is where the current either flows in to be sent to one of the sixteen outputs or where
the current flows out from one of the sixteen inputs. The sixteen inputs/outputs are labelled I0~I15. Finally
there are the four control pins labelled S0~S3. By setting these HIGH or LOW (Vcc or GND) you can
control which I/O pins the current flow is directed through. So how does that work? Once again reach for
the the data sheet and review the following table:
2 de 14 24/11/2016 0:53
Tutorial 74HC4067 16-Channel Analog Multiplexer Demultiplexer http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-an...
Limitations
Apart from the power supply requirements, there are a few limitations to keep in mind. Open you data
sheet and consider the DC Electrical Specifications table. The first two parameters show what the
minimum voltage that can be considered as a HIGH and the maximum for a LOW depending on your
supply voltage. The next item of interest is the ON resistance that is the resistance in Ohms ()
between one of the sixteen inputs/outputs and the common pin. When a channel is active, and a 5V supply
voltage, we measured a resistance of 56 without a load through that channel and the data sheet shows
other values depending on the current load and supply voltage. Finally, dont try and run more than 25 mA
of current through a pin.
Examples
Now to show an example of both multiplexing and demultiplexing. For demonstration purposes were
using an Arduino Uno-compatible board with the 74HC4067 running from a 5V supply voltage. Pin 15 of
the 4067 is set to GND, and control pins S0~S3 are connected to Arduino digital output pins D7~D4
3 de 14 24/11/2016 0:53
Tutorial 74HC4067 16-Channel Analog Multiplexer Demultiplexer http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-an...
respectively.
Multiplexing
This is where we select one input pin of sixteen and allow current to flow through to the common pin (1).
In this example we connect the common pin to the boards analog input pin so this can be used as a
method of reading sixteen analog signals (one at a time) using only one ADC. When doing so take note
of the limitations mentioned earlier take some resistance measurements in your situation to determine
what the maximum value will be from your ADC and calibrate code accordingly.
With both of the examples well use port manipulation to control the digital pins which are connected to
the 74HC4067s control pins. We do this as it reduces the code required and conceptually I feel its easier.
For example to select I/O 15 you need to turn on all the control pins so you just have to set Arduino
PORTD to B11110000 (which is binary 15 LSB first) and much neater than using four digitalWrite()
functions.
In the following example sketch, you can see how weve put the binary values for each control possibility
in the array byte controlPins[] which is then used to set the pins easily in void loop().
This simply sets each input pin in turn, then reads the ADC value into an array whose values are then
sent to the serial monitor:
4 de 14 24/11/2016 0:53
Tutorial 74HC4067 16-Channel Analog Multiplexer Demultiplexer http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-an...
Demultiplexing
Now for the opposite function sending current from the common pin to one of sixteen outputs. A fast
example of this is by controlling one of sixteen LEDs each connected to an output pin, and with 5V on the
74HC4067 common pin. We dont need current-limiting resistors for the LEDs due to the internal
resistance in the 74HC4067. Heres the sketch:
5 de 14 24/11/2016 0:53
Tutorial 74HC4067 16-Channel Analog Multiplexer Demultiplexer http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-an...
11 B00100000,
12 B10100000,
13 B01100000,
14 B11100000,
15 B00010000,
16 B10010000,
17 B01010000,
18 B11010000,
19 B00110000,
20 B10110000,
21 B01110000,
22 B11110000 };
23
24 void setup()
25 {
26 DDRD = B11111111; // set PORTD (digital 7~0) to outputs
27 }
28
29 void setPin(int outputPin)
30 // function to select pin on 74HC4067
31 {
32 PORTD = controlPins[outputPin];
33 }
34
35 void loop()
36 {
37 for (int i = 0; i < 16; i++)
38 {
39 setPin(i);
40 delay(250);
41 }
42 }
Conclusion
If youre considering the 74HC4067 or hadnt known about it previously, we hope you found this of
interest. If you have any questions please leave them below or privately via the contact page. And if you
made it this far check out my new book Arduino Workshop from No Starch Press.
6 de 14 24/11/2016 0:53
Tutorial 74HC4067 16-Channel Analog Multiplexer Demultiplexer http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-an...
In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things
on twitter, Google+, subscribe for email updates or RSS using the links on the right-hand column? And
join our friendly Google Group dedicated to the projects and related items on this website. Sign up its
free, helpful to each other and we can all learn something.
Bio
John Boxall
Founder, owner and managing editor of tronixstuff.com.
Like this:
Would an IC such as this be able to switch audio signals? If not this, is there an IC you would
recommend that would perform that function well?
Thanks!
Reply
Not this one the internal resistance will affect the amplitude. Nothing springs to mind right
now but if youre only wanting A-B switching perhaps DPDT relays would do.
Reply
2. gunndo says:
August 7, 2013 at 9:24 am
7 de 14 24/11/2016 0:53
Tutorial 74HC4067 16-Channel Analog Multiplexer Demultiplexer http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-an...
Reply
3. kyr says:
August 9, 2013 at 8:13 pm
Reply
4. Eimi says:
August 17, 2013 at 4:47 am
Hi, John.
Im trying to test Demux with an ARDUINO UNO and 74HC4067N but I cant.
Please, would you mind to check if the wiring I do is correct?
Reply
Dont connect the LED cathodes (-) pin to the 74HC4067, they should go to GND instead.
Also connect 5V for the LEDs to pin 1. Connect pin 15 to GND.
Reply
Eimi says:
August 17, 2013 at 10:33 pm
It works!!!, it works!!!
Great.
Thanks a lot for your attention and quickest help.
8 de 14 24/11/2016 0:53
Tutorial 74HC4067 16-Channel Analog Multiplexer Demultiplexer http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-an...
5. Eimi says:
August 22, 2013 at 5:40 am
Hi again, John.
Do you know if is possible to manage a 4-relay shield with this demux? (Arduino Uno -> demux ->
2 relay shields -> 8 solenoids)
If so, would you mind to tell me how must I do?
Thanks in advance.
Regards.
Reply
Only one output is selected at a time, you can turn it on/off using enable (pin 15). This
wouldnt be the part to control your relay shield. Try the MCP23017 or even a shift register.
Reply
6. Eimi says:
August 23, 2013 at 5:00 pm
Thanks again.
Reply
7. Marcwolf says:
December 1, 2014 at 3:18 pm
Great idea, and just what I am needing. I have 16 very small resistive sensors, and have been
grappling with a way to read them without also needing to clog up space with a resistor to V+ for
each one to get a reading.
With this chip I need only to put the one side of the sensor to ground, and then read the output pin
(pulled to V+ via a 10k) for each sensor..
The project is a way to put sensors in the mouth that can be activated with a tongue.. so space is
CRITICAL!!!
Many thanks
Marcwolf
Reply
9 de 14 24/11/2016 0:53
Tutorial 74HC4067 16-Channel Analog Multiplexer Demultiplexer http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-an...
Thank you for your feedback, its nice to hear someone is doing something useful.
Tongue sensor? Have fun
Reply
marcwolf says:
December 1, 2014 at 4:14 pm
Yep.. Tongue Sensor. For example many people wear false teeth that have a palette
shield that sits in the roof of the mouth. So why not use the same idea to mount a simple
shield up there and control things with your tongue when your hands are busy. You can
talk as well.
Even put a small joystick up there so you can control a wheel chair.. or animatronics in
a costume, or change a channel on a radio when you are climbing somewhere and
cannot use your hands.
Lots of possibilities but first find ways of very low profile sensors and I am using the
Force Sensor Resistors 0.2 diam.
Thanks for the reply
Marcwolf
Trackbacks/Pingbacks
Leave a Reply
Name (required)
Website
Visit tronixlabs.com
10 de 14 24/11/2016 0:53
Tutorial 74HC4067 16-Channel Analog Multiplexer Demultiplexer http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-an...
Helping you make it with Australia's best value for supported hobbyist electronics from adafruit, Altronics,
DFRobot, Freetronics, Pololu and more!
tronixstuff forum
es.aliexpress.com
Arduino Tutorials
Chapters 0 1 2 3 4
11 de 14 24/11/2016 0:53
Tutorial 74HC4067 16-Channel Analog Multiplexer Demultiplexer http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-an...
Chapters 5 6 6a 7 8
Chapters 9 10 11 12 13
Ch. 14 - XBee
Ch. 15 - RFID - RDM-630
Ch. 16 - Ethernet
Ch. 17 - GPS - EM406A
Ch. 18 - RGB matrix - awaiting update
Ch. 19 - GPS - MediaTek 3329
Ch. 20 - I2C bus part I
Ch. 21 - I2C bus part II
Ch. 22 - AREF pin
Ch. 23 - Touch screen
Ch. 24 - Monochrome LCD
Ch. 25 - Analog buttons
Ch. 28 - Colour LCD
Ch. 29 - TFT LCD - coming soon...
Ch. 30 - Arduino + twitter
Ch. 31 - Inbuilt EEPROM
Ch. 32 - Infra-red control
Ch. 33 - Control AC via SMS
Ch. 34 - SPI bus part I
Ch. 35 - Video-out
Ch. 36 - SPI bus part II
Ch. 37 - Timing with millis()
Ch. 38 - Thermal Printer
Ch. 39 - NXP SAA1064
Ch. 40 - Push wheel switches
Ch. 40a - Wheel switches II
Ch. 41 - More digital I/O
Ch. 42 - Numeric keypads
Ch. 43 - Port Manipulation - Uno
Ch. 44 - ATtiny+Arduino
Ch. 45 - Ultrasonic Sensor
Ch. 46 - Analog + buttons II
Ch. 47 - Internet-controlled relays
Ch. 48 - MSGEQ7 Spectrum Analyzer
First look - Arduino Due
Ch. 49 - KTM-S1201 LCD modules
Ch. 50 - ILI9325 colour TFT LCD modules
Ch. 51 - MC14489 LED display driver IC
Ch. 52 - NXP PCF8591 ADC/DAC IC
Ch. 53 - TI ADS1110 16-bit ADC IC
Ch. 54 - NXP PCF8563 RTC
Ch. 56 - MAX7219 LED driver IC
Ch. 57 - TI TLC5940 LED driver IC
Ch. 58 - Serial PCF8574 LCD Backpacks
Ch. 59 - L298 Motor Control
Ch. 60 - DS1307 and DS3231 RTC part I
12 de 14 24/11/2016 0:53
Tutorial 74HC4067 16-Channel Analog Multiplexer Demultiplexer http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-an...
13 de 14 24/11/2016 0:53
Tutorial 74HC4067 16-Channel Analog Multiplexer Demultiplexer http://tronixstuff.com/2013/08/05/part-review-74hc4067-16-channel-an...
Australian Electronics!
Buy and support Silicon Chip - Australia's only Electronics Magazine.
Interesting Sites
14 de 14 24/11/2016 0:53