Hi all,
I running a Mega 2560, to run a 16x16 LED Matrix. Transistors control each row and column, and there are 100k resistors to limit current to the board. Here's a schematic. http://i.imgur.com/nhjtxMx.png I was hoping to Direct Drive the matrix as seen here.Arduino Playground - DirectDriveLEDMatrix After Playing around with it for a bit, I managed to make the letters scroll correctly, but only on the bottom 15 rows, and the brightness isn't good enough. The letters are also upside down. I believe the issue is with the int pins[55] portion. Removing or adding pins makes the matrix not work at all. Here's the code.
[Here's the Code]
#include <FrequencyTimer2.h>
#define SPACE { \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0}, \
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 1, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, \
{1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, \
{1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, \
{1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0}, \
}
byte col = 0;
byte leds[16][16];
int pins[55]= {-1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,35,36,37,38,39,40,41,42,43,44,45,46,47,
48,49,50,51,52,53,54};
int cols[16] = {pins[23], pins[25], pins[27], pins[29], pins[31], pins[33], pins[35], pins[37],
pins[39], pins[41], pins[43], pins[45], pins[47], pins[49], pins[51], pins[53]};
int rows[16] = {pins[22], pins[24], pins[26], pins[28], pins[30], pins[32], pins[34], pins[36],
pins[38], pins[40], pins[42], pins[44], pins[46], pins[48], pins[50], pins[52]};
const int numPatterns = 3;
byte patterns[numPatterns][16][16] = {H,I,SPACE};
int pattern = 0;
void setup()
{
for (int i = 1; i<= 32; i++) {
pinMode(pins[i], OUTPUT);
}
for (int i = 1; i <= 32; i++) {
digitalWrite (cols[i - 1], LOW);
}
for (int i = 1; i <= 32; i++) {
digitalWrite (rows[i - 1], LOW);
}
clearLeds();
FrequencyTimer2::disable();
FrequencyTimer2::setPeriod(2000);
FrequencyTimer2::setOnOverflow(display);
setPattern(pattern);
// put your setup code here, to run once:
}
void loop()
{
pattern = ++pattern % numPatterns;
slidePattern(pattern, 60);
}
void clearLeds() {
for (int i = 0; i < 16; i++){
for (int j = 0; j < 16; j++){
leds[i][j] = 0;
}
}
}
void setPattern(int pattern) {
for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) {
leds[i][j] = patterns[pattern][i][j];
}
}
}
void slidePattern(int Pattern, int del) {
for (int l = 0; l < 16; l++) {
for (int i = 0; i <15; i++) {
for (int j = 0; j < 16; j++) {
leds[j][i] = leds[j][i+1];
}
}
for (int j = 0; j < 15; j++) {
leds[j][15] = patterns[pattern][j][0 + l];
}
delay(del);
}
}
void display() {
digitalWrite(cols[col], LOW);
col++;
if (col == 16) {
col = 0;
}
for (int row = 0; row < 16; row++) {
if (leds[col][15 - row] == 1) {
digitalWrite(rows[row], HIGH);
}
else {
digitalWrite(rows[row], LOW);
}
}
digitalWrite(cols[col], HIGH);
}
[/Here's the Code]
Any help is appreciated. Thanks