Hello everyone
For summer I'm starting to work on a little project which tries to make a MIDI Pad, like this, but a little bigger.
In fact, I want to make it 88 RGB leds, instead of 44.
I have already bought about 200 common anode RGB leds (I am working with a friend, so we'll make 2/3) and some TLC5940.
I have started to make some tests and the LEDs are very bright when powered by the TLC!
The schematic I am using for the control is this, as I am using two TLCs to drive the three colours of the matrix. For now however I am connecting together all the anodes, so that I don't have to work with multiplexing. The library that I am using is this one.
Some days ago, I started to do some multiplexing tests.
Here's a little schematic taht I prepared to show how the multiplexing I made works:
Every column shares the colours, instead every row shares its anode.
The rows have a BC327 that controls the power. As you can see, they're controlled by the TLC with this little sketch:
#include "Tlc5940.h"
#define ROWS 8
#define COLUMNS 8
#define BAUDRATE 115200
struct led {
uint8_t red;
uint8_t green;
uint8_t blue;
};
#define SV 0
uint8_t actualRow = 0;
led data[ROWS][COLUMNS];
uint8_t power = 16;
uint16_t val = 0;
void setup() {
Serial.begin(BAUDRATE);
for (byte i = 0; i < ROWS; i++) {
for (byte j = 0; j < COLUMNS; j++) {
data[i][j] = {255, 255, 255};
}
}
if (power > 16) {
power = 16;
}
Tlc.init(SV);
startXLATCallback();
Tlc.update();
}
void loop() {
if(val > 4095) {
val = 0;
}
setRow(0, {val, val, val});
val++;
}
void setRow(uint8_t row, led value) {
for(uint8_t i = 0; i < COLUMNS; i++) {
data[row][i] = value;
}
}
/** Sezione Multiplexing TLC5940 */
volatile void myXLATCallback() {
// Imposta i dati da inviare
setData();
//Invia i dati
while (Tlc.update());
set_XLAT_interrupt(); // Così la funzione verrà chiamata sempre.
}
// Funzione per far cominciare il ciclo richiamato ogni volta che viene terminato un ciclo XLAT.
void startXLATCallback() {
// La funzione interna della libreria richiamerà la nostra funzione.
tlc_onUpdateFinished = myXLATCallback;
myXLATCallback();
}
void setData() {
if (actualRow >= 8) {
actualRow = 0;
}
for (uint8_t i = 0; i < COLUMNS * 3; i++) {
if(i<8)
Tlc.set(i, data[actualRow][i].red * power);
else if (i >= 8 && i < 16)
Tlc.set(i + 1, data[actualRow][i].green * power);
else
Tlc.set(i + 2, data[actualRow][i].blue * power);
}
for (uint8_t i = 24; i < 32; i++) {
Tlc.set(i, ((i - 24 ) == actualRow) ? 4095 : 0);
}
actualRow++;
}
However, when I run it, the LEDS colour only of red and they're more dim than when running without the row control (simply giving a negaative signal to the transistor)
How can I fix this problem?