Go Down

Topic: Syncing/Linking Multiple Multiplexing (Read 351 times) previous topic - next topic

artuwap9

Hello everyone.

I am new in using multiplexers. I am trying to find a way to send data (voltage) to a specific output using the least pins as possible in Arduino. I know that using multiplexers can do only one output, and I am happy with that, but I would like to know if there is a way to sync or connect another multiplexer which would work independently but using the same pins of the Arduino.

For instance, in the attached image you can see 9 red LEDs, which I am able to control individually just fine. Let's say that I want the first red LED (C0) to turn on, but I would like to turn, for example, the last yellow LED (C8) simultaneously.

I have done some research but there is not much information about this, which makes me believe that is simply not possible, but I guess it's worth to give it a shot and ask to experienced people.

I got the following code from another forum, but it seems to work fine for using only one multiplexer.

Code: [Select]

const int SIG = 2;
const int controlPin[4] = {3, 4, 5, 6}; // 4 pins used  for binary output

const int muxTable[16][4] = {
    {0,  0,  0,  0}, // 1
    {0,  0,  0,  1}, // 2
    {0,  0,  1,  0}, // 3
    {0,  0,  1,  1}, // 4
    {1,  0,  0,  0}, // 5
    {1,  0,  0,  1}, // 6
    {1,  0,  1,  0}, // 7
    {1,  0,  1,  1}, // 8
    {0,  1,  0,  0}, // 9
    {0,  1,  0,  1}, // 10
    {0,  1,  1,  0}, // 11
    {0,  1,  1,  1}, // 12
    {1,  1,  0,  0}, // 13
    {1,  1,  0,  1}, // 14
    {1,  1,  1,  0}, // 15
    {1,  1,  1,  1}  // 16
};



void setup() {
  for(int i=0; i<4; i++) {
    pinMode(controlPin[i], OUTPUT);
    digitalWrite(controlPin[i], HIGH);   
  }
  pinMode(SIG, OUTPUT);
  digitalWrite(SIG, HIGH);
  Serial.begin(9600);
}

void loop() {
  for(int i=0; i<9; i++){
    channelControl(i);
    delay(1000);
  }
  Serial.println("==============="); 
}

void channelControl(int relayChannel)
{
    digitalWrite(controlPin[0], muxTable[relayChannel][0]);
    digitalWrite(controlPin[1], muxTable[relayChannel][1]);
    digitalWrite(controlPin[2], muxTable[relayChannel][2]);
    digitalWrite(controlPin[3], muxTable[relayChannel][3]);
 
       Serial.print(relayChannel);
       Serial.print (": ");
       Serial.print(muxTable[relayChannel][0]);
       Serial.print(muxTable[relayChannel][1]);
       Serial.print(muxTable[relayChannel][2]);
       Serial.println(muxTable[relayChannel][3]);
}


Thank you!!
Arturo

You do not use multiplexers for that, either shift register or IO-expanders.
Multiplexers are for multiple analog inputs to one pin, digital inputs are also done with the above solutions.

noiasca

#2
Oct 14, 2019, 07:45 pm Last Edit: Oct 14, 2019, 07:58 pm by noiasca
I am trying to find a way to send data (voltage) to a specific output using the least pins as possible in Arduino.
your schematic doesn't show what IC you are using. Therefore I doubt that you are using the LEDs wrong.

Regarding "the least pins as possible", this can be achieved with I2C port expanders - using only the two I2C pins.

for example:
MCP23017 I2C I/O Port Expander for 16 channels, up to 8 addresses which gives you up to 16x8 new ports

If you need to drive LEDs only, you better search for LED driver ICs. If you want to stick with two pins I2C for example the Holtek HT16K33 ... 8x16 LEDs per chip, up to 8 individual I2C addresses (1024 individual LEDs).

If you can use 3 pins, you could use a MAX7219/MAX7221 which is able to drive 8x8 LEDs per chip. One additional pin for each additional IC.
how to react on postings:
- post helped: provide your final sketch, say thank you & give karma.
- post not understood: Ask as long as you understand the post
- post is off topic (or you think it is): Stay to your topic. Ask again.
- else: Ask again.

PaulRB

#3
Oct 14, 2019, 07:55 pm Last Edit: Oct 14, 2019, 08:01 pm by PaulRB
One additional pin for each additional IC.
Not necessarily. If you chain the chips, connecting data out pin from one to data in pin of the next, you need only 3 pins for any number of chips.

Go Up