programing and wiring 2 Multiplexer / demultiplexer with arduino

hello I am very pleased to participate in this community!
I recently developed an autonomous airship project. For this project I wish to receive information from 30 sensors and send commands to actuators 18.
I have a Arduino mini pro 328 three multi / demultiplexers 74HC4067 buy from Sparkfun
I learn about their installation and programming but I do not see:

  1. how the physical cable to the card (ie if the 2 multiplexer and demultiplexer are on the same digital inputs?)
  2. how to manage these two groups in programming

thank you to you!
to help me in this project

You cannot use a 74HC4067 to multiplex outputs. Well you can but only one output can be active at any one time and all the rest of the outputs will be high impedance. You are not the first to be caught out about this but there is a lot of wrong information about.
To get multiple outputs you need to use either a shift register, port expander (like the 23S17), or something with a latch.
For examples of these see my projects:-
http://www.thebox.myzen.co.uk/Hardware/CNC_Conversion.html - uses port expander
Transistor Tester - uses latched multoplexer

To control these, you connect 4 arduino outputs to the S0-S1-S2-S3 pins, that will select which I/O path thru the device will be connected.
Then you will have 4 more arduino outputs that will function as chip selects. You will write out S0-S3, then enable one device at a time.

Connect the common I/O pin (pin 1) for the 2 sensor selector parts together and connect to your digital input pin.
The combination of S0-S3 and the 2 enable pins will select which of the 32 outputs will appear at your digital input pin.

Connect the common I/O pin for the 2 actuator selector parts together and connector to your digital output pin.
The combination of S0-S3 and the 2 enable pins will select which of the 32 outputs will follow the actions of the digital output pin.
Be aware that when no outputs are selected, the pins will not be Hi or Lo, you will need a pullup or pulldown resistor to put the actuator in its Off state.

If you want to use just 1 arduino pin to both read the sensors and drive the actuators, that is possible also.
Connect the common I/O pin from all devices to the arduino.
Your code will have to change the mode of the pin as you use it:
for reading, pinMode(ioPin, INPUT);
set S0-S3, enable one of the sensor input parts
then read the signal

for writing, pinMode(ioPin, OUTPUT);
set S0-S3, enable one of actuator output parts
then write your actuator signal hi/lo, or lo/hi, as needed.

Does that make sense?

great!
thanks Grumpy_Mikegood projets...

CrossRoads
yes that make sense to me!
2 solutions . can you make a drawing of them ?
because y dont read english very well and y dont want too make mistake
y dont need 32 actuator only 18 that s why y try to use only one demultiplexer

y try to use tree 74 hc 6067 bread bord

thanks a lot and have a caribeean sun

This is the way to do it with latched outputs, so that once you have set an output to a level it stops at that level.
Note this was drawn for an old computer, the reference to a "User Port" is what you would call an arduino pin. Note you can use any arduino pins but avoid pins 0 and 1 as they are for the serial comms.

hello
my loggin name is angoo
and y am talking with you in the forum about multiplexing/demultiplexing
i m work on it
but i dont know how to post image and code
there is some information on the old forum but i dont find in this one
thanks for help!

Just sent you a PM but for others.
For code click the # icon above the reply box and paste the code between the brackets that pop up.
For a picture click the Additional Operations... below the box and brows for your picture.

thank
Grumpy
for the explication

the code downside it made by SHYWODD
on the french forum

/*
S0 -> digital 7
S1 -> digital 8
S2 -> digital 9
S3 -> digital 10
Z -> analog 0

E -> 0v
gnd -> 0v
vcc -> 5v
*/

void setup(){
Serial.begin(9600);
pinMode(7,OUPUT);
pinMode(8,OUPUT);
pinMode(9,OUPUT);
pinMode(10,OUPUT);
}

void loop(){
digitalWrite(7,LOW);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW); // Y0
Serial.println(analogRead(A0));

digitalWrite(7,HIGH);
digitalWrite(8,LOW);
digitalWrite(9,LOW);
digitalWrite(10,LOW); // Y1
Serial.println(analogRead(A0));

digitalWrite(7,LOW);
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
digitalWrite(10,LOW); // Y2
Serial.println(analogRead(A0));

digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
digitalWrite(9,LOW);
digitalWrite(10,LOW); // Y3
Serial.println(analogRead(A0));
// etc .....
}

it s ok for the code part but not for picture !
what i do
click on insert image
it give me brows like that/img / /img/ (/ are for explication)
clik on additional options
there is attach
i make "parcourir" and find my picture
for example : C:\Users\tauliaut\Desktop\demux-demo.jpg
i paste it on the /img]C:\Users\tauliaut\Desktop\demux-demo.jpg[/img/

i make prewiew
it wrong!

I don't believe you can use
[ img ] link to your desktop [ /img ]
for images on your computer. You need to use the Reply and Additional Options to attach pictures that will then upload as part of your post.

This is used to link to images you have uploaded to the internet somewheree
[ img ] http://www.link to flickr.com/your_picture.jpg [ /img], that knd of link.

OK angoo I see your picture and your code now what is your question?

i started from the CROSSROAD picture
and make a one that s close off my mind

2 multiplexer and one demultiplexer
do you thing it s good?
thank a lot
![](http://C:\Users\tauliaut\Desktop\4067_mux-demux version 2.jpg)

You do realize that you can't use 4067s for outputs unless you only need one output on at a time, it's been stated a couple of times but I'm not sure you've pick up on it.

BTW, your picture links to your C drive, that ain't gonna work :slight_smile:


Rob

The select inputs to the first level of multiplexers are not going anywhere, so there will be no way to control them. Unless that is they are joined to the others. When drawing a schematic you should not have lines that cross and join together unless you put a dot on the intersection.

You also need supply decoupling as well.

The select lines have squares, they are just a little hard to see due to the way the schematic was captured & posted.

Hi, I kind of have the same question, so I thought I might as well use this thread to post it in.

Im trying to use http://uk.rs-online.com/web/search/searchBrowseAction.html?method=searchProducts&searchTerm=74hc151n&x=0&y=0 this multiplexer to read a matrix of pressure pad placed on the floor. With pressure pads i mean aluminium foil wrapped cardboard > http://supersoda.com/detail.php?id=00000000036.

I tried to wire the 4051 multiplex/demultiplex example from tom igoe. But according to some comments I also need a pull down resistor and an capacitor to deal with multiple presses at once. Could anyone tell me what kind of resistor/capacitors I need and how to solder them correctly to the arduino ?

You say matrix, but what you really mean is a collection of seperate pads and you want to sense when any are activated.
The pads themselves are passive devices, yes? Really just a switch.
So wire each switch with one side to a 4051 input and a pullup resistor to +5v, and the other side to ground.
Then just scan thru the addresses reading the inputs one by in a loop, when you see a 0 you act on the switch(es) that is(are) closed.
No pulldown resistors, no capacitors.
Your loop can be a blink without delay kind of thing. Every XXmS you read all 16 inputs and set fllag if one is closed. Then you have a section of code that turns on lights or makes a sound or whatever when you see a flag is set, and ignores any new setting of the same flag until your lights/sound whatever is done.

Thanks for the fast reply!,

CrossRoads:
You say matrix, but what you really mean is a collection of seperate pads and you want to sense when any are activated.

No, i really mean a matrix, so that i can read through the x and y rows to determine the location of the pad being pressed. Is this possible?
Or does every pad has its own binary code, so that I can say: 1001 = left upper corner and 0101 = right upper corner of my pressure pad matrix.

CrossRoads:
Every XXmS you read all 16 inputs and set fllag if one is closed. Then you have a section of code that turns on lights or makes a sound or whatever when you see a flag is set, and ignores any new setting of the same flag until your lights/sound whatever is done.

What do you mean with flag?, could this be a boolean being set to true if a certain switch is on?

So a matrix then which is really just a big keypad.
How many? With a 4x4 matrix, you can use just the keypad library, no 4051 needed at all.
Flag, yes, generally boolean.
Altho for a keypad, you would hopefully just get 1 location pressed at a time, then you can use switch:case to direct your actions.