I am new to electronics. I have a good amount of programming under my belt however.
I want to know if I am multiplexing correctly or not. My intended output is how I want it, but I am not sure if I implemented it how it's supposed to be, i.e. am I potentially damaging my equipment.
I have 6 RGB LEDs hooked up to my arduino, let's called them L1 - L6.
I have each R, G, and B pin on L1 - L3 connected in parallel, and the same for L4 - L6. Then I have ground on L1 and L4 connected in parallel, and the same for L2 to L5, and L3 to L6.
So this gives me 6 pins to supply voltage to, to which I put a 220 ohm resistor in each one. Then it gives me 3 different spots for ground.
My question is about the ground. How should I control the different 'pins' for ground.
This is what I have right now, and it works, but I don't know if this is dangerous to my equipment for some reason.
I have the 3 ground pins connected to the Arduino in 3 different pins, 7, 4, and 2.
Setup() I configure these 3 pins as outputs, and I later found out in order to keep them all 'off' I need to set them all to high.
So then in order to turn L1 on to red, I need to turn its red pin to high, but turn its ground pin to low, then L1 turns on.
Using this same technique, I am able to get every LED to every desired color. So I mean it works. But why is this? Is this how I should be doing it? I understand LEDs polarity matters, but why would supplying its cathode with voltage make it turn off? That's the part I'm worried about, am I destroying my LEDs by doing this?
Any and all help much appreciated!
Here is how I have it all wired up for clarity.