Go Down

Topic: programing and wiring 2 Multiplexer / demultiplexer with arduino (Read 8119 times) previous topic - next topic

CrossRoads

The select lines have squares, they are just a little  hard to see due to the way the schematic was captured & posted.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

lightbubbles

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 ?

CrossRoads

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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

lightbubbles

Thanks for the fast reply!,


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.



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?

CrossRoads

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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

lightbubbles

I think the matrix is going to be 8 by 8 pads, I already have two multiplexers > http://uk.rs-online.com/web/search/searchBrowseAction.html?method=searchProducts&searchTerm=74hc151n&x=0&y=0. Wired like the example on the right at the 4051 page.
Could you point out on the circuit where the pull-up resistors have to be? ..

thanks for your input !

CrossRoads

With an 8x8 keypad, you can connect that up directly to an arduino (which has 20 digital inputs).
Then use the keypad library to read them.
http://www.arduino.cc/playground/Code/Keypad
You will expand this section of code
Code: [Select]

// all this stuff goes before void setup()
#include <Keypad.h>         // Matrix Keypad library

const byte rows = 4; //four rows << 8 rows
const byte cols = 3; //three columns << 8 columns
char keys[rows][cols] = {
  {'1','2','3'},  // call these what you'd like: A1 thru A8, B1 thru B8, etc
  {'4','5','6'},
  {'7','8','9'},
  {'#','0','*'}
};
byte rowPins[rows] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad  << assign your 8 pins here
byte colPins[cols] = {8, 7, 6}; //connect to the column pinouts of the keypad  << assign the other 8 pins here
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols );

then write your code that will read it in void loop:
Code: [Select]

void loop(){
    // go read the keypad
  char key = keypad.getKey();                 // reading the keypad
  if(key)                                     // same as if(key != NO_KEY)- did something change?
  {
// a key was pressed, do something
switch (key){
case "A1":
// button A1 code
break;
case "A1":
// button A2 code
break;
//etc
case "H8":
//button H8 code
break:
}  // end switch
} // end if (key)

// do other stuff while waiting for  a key press
} // end void loop
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up