How to controll an 7x5 LED matrix with the TLC 5940

Hello everyone,

I built an 7x5 LED Matrix and I am a bit frustrated, because I do not know how to control every LED inidividiually. I used the "Tlc5940" libary to control the leds and I use a software matrix for the picture which I want to show on the Hardware Led Matrix. Is there an option, that I can use a bool instate of an unsigned int array and how can I realise this in my class?

#include "Tlc5940.h"  //don't forget to download the Tlc5940 lib from arduino playground ( http://tlc5940arduino.googlecode.com/files/Tlc5940_r014_2.zip )
#include "Matrix_LED.h"
#define RowOne 8      //Gate of 1.MOSFET which connects to Row "a" (anodes of all LEDs in Row "a")
#define RowTwo 7      //Gate of 2.MOSFET which connects to Row "b" (anodes of all LEDS in Row "b")
#define RowThree 6    //Gate of 3.MOSFET which connects to Row "c" (anodes of all LEDs in Row "c")
#define RowFour 2     //Gate of 4.MOSFET which connects to Row "d" (anodes of all LEDs in Row "d")
#define RowFive 4     //Gate of 5.MOSFET which connects to Row "e" (anodes of all LEDs in Row "e")
#define bright 2000   //Helligkeit der eigenen LED 


Matrix myMatrix = Matrix(5,7); //5x7 LED Matrix 
unsigned int PicE[5][7] = {      //Buchstabe E soll angezeigt werden 
{1,0,0,0,0,0,0},
{0,1,0,0,0,0,0},
{0,0,1,0,0,0,0},
{0,0,0,1,0,0,0},
{0,0,0,0,1,0,0}
};


void setup(){  
//Anlegen eines Hardware Array
unsigned int List[5] = {RowFive, RowFour,RowThree,RowTwo,RowOne};  
Tlc.init();
myMatrix.get_RowList(List); //Ausgänge der Mosfets bekommen
myMatrix.set_RowList(); //Setzen der Ausgänge 
myMatrix.set_LED(PicE[5][7],true,2000);
}

void loop(){
myMatrix.Matrix_Update(0.01);
}
#ifndef Matrix_LED
#define Matrix_LED

#include <Arduino.h>
#include "Tlc5940.h"


class Matrix{
  //row = Zeile
  //column = Spalte
  private:
    unsigned int y;//Zeile oder Höhe
    unsigned int x;//Spalte oder Länge
    unsigned int** Matrix_led; //Dynamisches 2d Array Zeiger 
    unsigned int* RowHDList; //Hardware Liste der Ausgänge von den Mosfets Addresse wird gespeichert 
  public:
    Matrix(unsigned int r, unsigned int c); //Konstruktor zur Initialiserung der Matrix
    ~Matrix(); //Dekonstruktor zur Freigabe des Speichers 
    void Matrix_Update(unsigned int time); //Update der Matrix 
    void set_LED(unsigned int** BitPic, bool IsOn, unsigned int bright); //Setter Methode um Bitmuster zu bekommen
    void get_RowList(unsigned int* List); //Methode um Werte der RowHDList zu erhalten 
    void set_RowList(); //Soll die Zeilen als AUsgang setzen im Setup
};
#include <Arduino.h>
#include "Matrix_LED.h"
#include "Tlc5940.h"

Matrix::Matrix(unsigned int r, unsigned int c): y(r), x(c)
{ //Direktes initialiseren von x und y  
  Matrix_led = new unsigned int*[y]; //Erstellt Zeilen
  for(int i = 0; i < y; i++){
    Matrix_led[i] = new unsigned int[x](); //Erstellt Spalten und initialisert alles mit 0
  }

}
//Gibt Speicher korrekt frei um Speicherlecks zu vermeiden 
Matrix::~Matrix(){
  for(int i =0; i < y; i++){
    delete[] Matrix_led[i]; //Spalten freigeben 
  }
  delete[] Matrix_led; //Zeilenarray freigebn 
}



void Matrix::set_LED(unsigned int** BitPic, bool IsOn, unsigned int bright){
  //Größe soll der LED Matrix soll übergeben werden 
    if(IsOn == true) { //Wenn set_LED freigegeben soll das Bild ausgeführt werden 
      for(int i = 0; i < y; i++){ //Zeile wird durchlaufen
        digitalWrite(RowHDList[i],LOW); //Einschalten der Zeile
        delay(200);
        for(int j = 0;j < x; j++){ //Spalte wird durchlaufen
          if(BitPic[i][j] == 1){ //Prüfen ob LED angehen soll
            Tlc.set((j+1),bright); //Einschalten der Spalte des TLC5940
            Tlc.update();
            delay(1);
            }
            Tlc.clear();
            digitalWrite(RowHDList[i],HIGH);
        }  
      }
    
  }
}


void Matrix::get_RowList(unsigned int* List){
  //Werte von List werden in RowHDList reingeschrieben
 // RowHDList[y]; //Festlegen Größe der Hardware Liste
  for(int l=0; l < y; l++) { //y ist die Höhe der Led Matrix 
    RowHDList[l] = List[l]; //Kopieren der Werte in RowHDList (privat)
  } 
}


void Matrix::set_RowList(){
//Soll die ganze Zeile als AUsgang setzen von RowList
  for(int z = 0; z<y; z++){
    pinMode(RowHDList[z],OUTPUT);
  }
}

void Matrix::Matrix_Update(unsigned int time){    
    for(int i=0; i < y; i++){
        digitalWrite(RowHDList[i],HIGH); //Ausschalten der Zeile
        delay(time);
        for(int j=0; j < y; j++){
          //Wenn Zeile eingeschaltet soll diese nicht gleichzeitig ausgeschaltet werden 
          if(j != i){ 
            digitalWrite(RowHDList[j],LOW); 
            delay(time);
          }
        }
    }
}

The TLC5940 has 16 direct drive channels that can only sink current.

What is your overall plan for using that to control 35 LEDs independently?

Consider using the MAX7219 instead, if the LED matrix wiring allows that.

per @jremington your hardware is not capable of doing what you want. You will have to change the way you want it to operate or change the hardware. You can use more then one chip if you want. Here is a link to some boards. SparkFun LED Driver Breakout - TLC5940 (16 Channel)

Ok maybe I will look for an alternative hardware I copied the hardware, because I wanted to code better software with object-oriented programmaing, that I am able to build a matrix on software side as big is want