Lighting more than one LED in the same multiplexer

I guess that lighting more than one LED in the same multiplexer simultaneously is not possible, right? What I can think of is faking it by changing between the LEDs you want lit by setting the respective digital pins high or low…
For example if I want LED 0 and LED 1 lit, I should switch between 0000 and 0001 in a loop (it’s a 16 channel multiplexer). Am I right till here, or am I getting something wrong?
If I’m right, since I don’t know before hand which LEDs I want lit (I will be sending data from Pure Data), what’s the best way to set this dynamically? For now I’m using an array of fixed size and I’m setting it’s elements using Serial.parseInt(); then I’m reading through the array with a for loop. Here’s the code for details

#define CONTROL0 2
#define CONTROL1 3
#define CONTROL2 4
#define CONTROL3 5

const int muxLed = A0;
int myLeds[16];

void setup() {
  Serial.begin(9600);
  pinMode(CONTROL0, OUTPUT);
  pinMode(CONTROL1, OUTPUT);
  pinMode(CONTROL2, OUTPUT);
  pinMode(CONTROL3, OUTPUT);
  pinMode(muxLed, OUTPUT);
}

void loop() {
  while (Serial.available() > 0) {
    myLeds[0] = Serial.parseInt(); 
    myLeds[1] = Serial.parseInt(); 
    myLeds[2] = Serial.parseInt(); 
    myLeds[3] = Serial.parseInt();
    myLeds[4] = Serial.parseInt(); 
    myLeds[5] = Serial.parseInt(); 
    myLeds[6] = Serial.parseInt(); 
    myLeds[7] = Serial.parseInt();
    myLeds[8] = Serial.parseInt(); 
    myLeds[9] = Serial.parseInt(); 
    myLeds[10] = Serial.parseInt(); 
    myLeds[11] = Serial.parseInt();
    myLeds[12] = Serial.parseInt(); 
    myLeds[13] = Serial.parseInt(); 
    myLeds[14] = Serial.parseInt(); 
    myLeds[15] = Serial.parseInt();
    if (Serial.read() == '\n') {
      for (int q = 0; q < 16; q++) {
        digitalWrite(CONTROL0, (myLeds[q]&15)>>3);
        digitalWrite(CONTROL1, (myLeds[q]&7)>>2);
        digitalWrite(CONTROL2, (myLeds[q]&3)>>1);
        digitalWrite(CONTROL3, (myLeds[q]&1));
        digitalWrite(muxLed, HIGH);
      }
    } else {
        digitalWrite(muxLed, LOW);
    }
  }
}

But this is not working. I’m sending lists from Pure Data e.g. 0,1,2,3 etc. What am I doing wrong here? BTW, there’s no reference for Serial.parseInt() in Arduino’s website.

Thanks

What am I doing wrong here?

Trying to multiplex over a serial link. The code to do the multiplexing should be in the arduino. Exactly how have you got things wired up? You are not trying to use a data selector as an output multiplexer I hope.

I'll look up the serial link you're mentioning. I have digital pins 2-5 going to the multiplexer and analog 0 to its sig_pin. Then I have each LED's anode going to one of the 16 pins of the multiplexer through a 220 Ohm resistor and the cathode to ground. I want to use this for a controller for music I'm building, so I want to have LEDs for visual feedback for the push buttons that I'm using.

The serial link is the USB cable connecting your arduino to your computer. What chip are you using as a multiplexer?

Well, I'm connected over a USB. I can send a single number and set one LED at a time. My problem is when it comes to more. I'm using this one CD74HC4067 got info and all from herehttp://bildr.org/2011/02/cd74hc4067-arduino/

Sorry but that is a rubbish tutorial and that circuit should not be used for anything other than a demo.

If you insist on using it then the arduino must do the multiplexing of all 16 bits. Then your serial commands just set and clear a single bit in the int that you are multiplexing. You cannot send commands fast enough or reliable enough to do it from the PC side.

However the real soloution is to do your port expansion with the right sort of chip. People often use shift registers but there are SPI chips and I2C chips you can use as well.

Would something like this http://arduino.cc/en/Tutorial/ShiftOut be more appropriate then?

alexandros301: Would something like this http://arduino.cc/en/Tutorial/ShiftOut be more appropriate then?

Yes that is better only do not connect the capacitor to the latch pin that is wrong. Connect the capacitor from ground to the 5V supply of the chip.

I'll give that a try, thanks.