Total noob to Multiplexing (and Aduino in general)

I bought my first Arduino at a Radio Shack Saturday, and it is very intuitive. I want to control more things than I have pins, so I need to multiplex.
So I understand If Blue 1 is written high, and Black 1 low, then A turns on. What I don't understand is what the others are supposed to be set to. Can somebody explain it to me?

BlackFang:
So I understand If Blue 1 is written high, and Black 1 low, then A turns on.

Correct.

BlackFang:
What I don't understand is what the others are supposed to be set to. Can somebody explain it to me?

If you only want A, not BCD then Black 234 should be high (current doesn't flow from +5V to +5V).

Ok, that makes since. Blue 1 high, Black 1 low, and Black 2,3,4 high. But what do Blue 2, 3, 4 do then? If low, B, C, and D will activate, but if high, E, I, and M will.

BlackFang:
But what do Blue 2, 3, 4 do then?

They can be low. LEDs are diodes so no current should flow back to them from the black pins.

Even better: Disconnect them completely by setting them as INPUTs with LOW state.

(For the pedants: Yes I know they're not completely disconnected, but it's close enough...)

Ok, so LEDs have built in diodes to prevent back flow. Now I get Multiplexing, thank you.
So if I wanted to switch on some transistors instead of LEDs, things get a bit more complicated...

BlackFang:
Ok, so LEDs have built in diodes to prevent back flow. Now I get Multiplexing, thank you.

No, LEDs are diodes - that's the 'D' in their name.

BlackFang:
So if I wanted to switch on some transistors instead of LEDs, things get a bit more complicated...

Yes. Arduino pins can only supply about 40mA so driving a row of LEDs from a pin doesn't work very well. You'll need PNP transistors on the blue and NPN transistors on the black, each one with it's own resistors, etc.

Most people use chips to drive matrices because it's much easier than wiring up rows of transistors. You also have a much better chance of all the LEDs having the same brightness when you use a chip.

eg. A MAX7219 will drive a matrix directly.

Well, I actually need to drive about 20ish vibration motors, not LEDs. But I think most of the concept is the same. I would use a 5 by 5 array to get 25 outputs for the cost of 10 pins. I would need 5 NPNs and 5 PNPs to control the flow of my non-Arduino power through the matrix. I would also need 5 diodes to prevent reverse flow on the positive lines. Is this correct?

BlackFang:
Well, I actually need to drive about 20ish vibration motors, not LEDs. But I think most of the concept is the same.

Yes.

BlackFang:
I would use a 5 by 5 array to get 25 outputs for the cost of 10 pins. I would need 5 NPNs and 5 PNPs to control the flow of my non-Arduino power through the matrix. I would also need 5 diodes to prevent reverse flow on the positive lines. Is this correct?

Transistors are diodes, too... :slight_smile:

Or, you could use shift registers capable of supporting higher current/perhaps higher voltage to support your motors.
Such as 3 or 4 TCIP6B595 shift registers (or other model such as TCIP6D595, check their specs, avnet.com carries many of them) to sink current thru the motors to turn them on. Just 3 IO pins needed; clock, datapin latch pin (or SCK, MOSI, SS, if using SPI for faster control).

That will also give better motor performance if you want more than 1 on at a time and need them on at full power.

So no extra diodes, cool. You have been a very big help. Would something like this be the way to wire it if I went with transistors?

I will look into shift registers some more...

Something like that, yes...

Now connect 2 shift registers to the Red & Black base resistors.