Charlieplex 4 RGBs

I am attempting to Charlieplex 4 RBGs but so far I'm not having any luck. Here is the code I have attempted to edit and the schematic (attached) on how I've wired them up. Any help is GREATLY appreciated!

#define CHARLIE_PINS  4
#define CHARLIE_FIRST 8

// Setup the memory
#define CHARLIE_COUNT CHARLIE_PINS*(CHARLIE_PINS-1)

// Charlie Level (0 = off, 255 = max)
#define CHARLIE_LOW    0
#define CHARLIE_HIGH 255

#define CHARLIE_OFF     0
#define CHARLIE_MAX   255

// Charlie Levels for anode/cathode pin-pairs
uint8_t charliePins[CHARLIE_PINS][CHARLIE_PINS];

#define CHARLIE_GREEN 0
#define CHARLIE_BLUE  1
#define CHARLIE_RED   2

//int charlieRGB[CHARLIE_PINS][3] = {{1, 2, 3}, {2, 3, 0}, {3, 0, 1}, {0, 1, 2}};
int charlieRGB[CHARLIE_PINS][3] = {{0, 1, 2}, {3, 0, 1}, {2, 3, 0}, {1, 2, 3}};

void charlieClear() {
  for(int i = 0; i < CHARLIE_PINS; i++) {
    for(int j = 0; j < CHARLIE_PINS; j++) {
      charliePins[i][j] = CHARLIE_OFF; 
    }
  } 
}

void charlieSetAll() {
  for(int i = 0; i < CHARLIE_PINS; i++) {
    for(int j = 0; j < CHARLIE_PINS; j++) {
      charliePins[i][j] = CHARLIE_MAX;
    }
  } 
}

void charlieSetAllLevel(uint8_t level) {
  for(int i = 0; i < CHARLIE_PINS; i++) {
    for(int j = 0; j < CHARLIE_PINS; j++) {
      charliePins[i][j] = level;
    }
  } 
}

void charlieWrite(int src, int dst, uint8_t level) {
 
  charliePins[src%CHARLIE_PINS][dst%CHARLIE_PINS] = level;
 
}

// current line displayed
int charlie_line = CHARLIE_PINS-1;

void charliePlexLine(uint8_t level) {
 
  // Disable last line displayed
  pinMode(CHARLIE_FIRST+charlie_line, INPUT);

  if(++charlie_line >= CHARLIE_PINS) charlie_line = 0; 
  int i = charlie_line;
  int MasterPin = CHARLIE_FIRST+i;

  // Use others as follow pins (HIGH or INPUT)
  for(int j = 0; j < CHARLIE_PINS; j++) {
    int SlavePin = CHARLIE_FIRST+j;
   
    if(MasterPin != SlavePin) {
      if(charliePins[i][j] > level) {
        pinMode(SlavePin, OUTPUT);
        digitalWrite(SlavePin, LOW);
      } else {
        pinMode(SlavePin, INPUT);
      }
    }
  }
  pinMode(MasterPin, OUTPUT);
  digitalWrite(MasterPin, HIGH);   
}

void charliePlex() {
 
  // Set one leadpin (LOW)
  for(int i = 0; i < CHARLIE_PINS; i++) {
    for(int j = 0; j < CHARLIE_MAX; j++) {
      charliePlexLine(j);
      delayMicroseconds(10);
    }
  }
}

// the setup routine runs once when you press reset:
void setup() {

}

void loop() {
 
  
  //Sample 1: First LED(0,1) "On"
  //
  charlieClear();
  //charlieWrite(4,1,CHARLIE_MAX);
  charlieWrite(2, charlieRGB[3][CHARLIE_GREEN],CHARLIE_MAX);
  charliePlex();
  


  /*
  // Sample 2: Dimm White
  for(int i = 0; i < 8; i++) {
    charlieSetAllLevel(1<<i);
    charliePlex();
  }
  for(int i = 7; i > -1; i--) {
    CHARLIE_PINS(1<<i);
    charliePlex();
  }
  //*/
 
  /*
  // Sample 3: Alternate the COLORS
  charlieClear();
  for(int i = 0; i < CHARLIE_PINS; i++) {
    charlieWrite(i, charlieRGB[i][CHARLIE_RED], CHARLIE_MAX);
    delay(500);
  }
  charliePlex();

  charlieClear();
  for(int i = 0; i < CHARLIE_PINS; i++) {
    charlieWrite(i, charlieRGB[i][CHARLIE_GREEN], CHARLIE_MAX);
    delay(500);
  }
  charliePlex();

  charlieClear();
  for(int i = 0; i < CHARLIE_PINS; i++) {
    charlieWrite(i, charlieRGB[i][CHARLIE_BLUE], CHARLIE_MAX);
    delay(500);
  }
  charliePlex();
  //*/

}

Where are the resistors?

Sorry, forgot it on my schematic I'll update my schematic.

There are 10 K Resistors on each RGB line of every LED.

You need a resistor in each colour of LED not one for all three colours. A value of 10K is way too high.

I have updated the schematic. The 10K resistors was not true (different project I'm working on). The updated schematic reflects the values of the resistors I have used. Each red line has a 270 Ohm resistor and all the Green and Blue lines have 330 Ohm resistors.

Sorry..

tcox8:
Each red line has a 270 Ohm resistor and all the Green and Blue lines have 330 Ohm resistors.

Still getting mixed up? The resistors for the red leds should be higher than those for green & blue. Otherwise all colours will be too red.

I can individually light the RBG's without charlieplexing and have no problems. When running the above code I can't seem to get them to light up correctly. When trying to address 1 led and make it light up a certain color (we'll say green) I am instead getting 3 leds that light up (one red, one is green, and the other is purpleish). I'm not sure if it is a coding issue or a wiring issue (I've checked and rewired about 10 times now).

Charlieplexing is kicking my butt!

I'm having difficuly understanding your code. What does this line do, for instance?

CHARLIE_PINS(1<<i);

The whole code seems more complex than i expected, as though you plan to have some advanced function that isn't being used yet. Can you explain what you want to achieve?

That's a great place to start! The code I actually got online and have a hard time understanding as well but I get the general idea (i think).

My goal is to have 4 RGBs that are charlieplexed (to save pins) that will all light up the same color based on an external input (a switch).

tcox8:
My goal is to have 4 RGBs that are charlieplexed (to save pins) that will all light up the same color

If you want them all to be the same colour, you don't need to charlieplex them. Just connect them in parallel.

Yep.. I am dumb. Didn't even think about that...

So you can just use 3 pwm pins to control the colour of all 4 leds. If you want to get more brightness out of them, you can reduce the series resistors down if you add 3 npn transisors (e.g. bc337).

I hooked them up in parallel. Everything was working except for lighting up blue. I decided to go back and check each color on every led. Found out that on one of my led's i had a hairline solder short on some pins. So that probably explains my charlieplexing problem. But now having them in parallel is working as expected.

Thank you SO much for your help!!!