# 6x6 LED Matrix, help!

Hi!

I've adapted the "Direct driving of an 8x8 LED matrix" code to use with Xbee.

First I used a 4x4 LED Matrix and it was all working well, even when I changed from an Arduino to a Lilypad.
But now I'm trying to do it with a 6x6 LED Matrix and it only plays the first frame and freezes on it not playing the remaining frames.

I don't know what I can be possibly be doing wrong, I've tried everything and showed the code to my teacher and my boyfriend who know a little about programming and they don't know what's wrong either.

Can anyone help me please?

showed the code to my teacher and my boyfriend who know a little about programming

Maybe if you showed us your code (and schematic)... The code is this: (I’ve simplified it to put it here because it’s big)

#include <FrequencyTimer2.h>

#define A {
{ 1, 1, 1, 1, 1, 1},
{ 1, 1, 1, 1, 1, 1},
{ 1, 1, 1, 1, 1, 1},
{ 1, 1, 1, 1, 1, 1},
{ 1, 1, 1, 1, 1, 1},
{ 1, 1, 1, 1, 1, 1},
}

#define B {
{ 1, 1, 0, 0, 1, 1},
{ 1, 1, 0, 0, 1, 1},
{ 1, 1, 0, 0, 1, 1},
{ 1, 1, 0, 0, 1, 1},
{ 1, 1, 0, 0, 1, 1},
{ 1, 1, 0, 0, 1, 1},
}

#define C {
{ 1, 1, 1, 1, 1, 1},
{ 1, 1, 1, 1, 1, 1},
{ 1, 1, 1, 1, 1, 1},
{ 1, 1, 1, 1, 1, 1},
{ 1, 1, 1, 1, 1, 1},
{ 1, 1, 1, 1, 1, 1},
}

byte col = 0;
byte leds;

// pin[xx] on led matrix connected to nn on Arduino (-1 is dummy to make array start at pos 1)
int pins= {-1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13};

// col[xx] of leds = pin yy on led matrix
int cols = {pins, pins, pins, pins, pins, pins};

// row[xx] of leds = pin yy on led matrix
int rows = {pins, pins, pins, pins, pins, pins};

byte propria={
A,B,C
};

int pattern = 0;
int frame = 0;

void setup()
{

for (int i = 1; i <= 12; i++) {
pinMode(pins*, OUTPUT);*

• }*

• // set up cols and rows*

• for (int i = 1; i <= 6; i++) {*

• digitalWrite(cols[i - 1], LOW);*

• }*

• for (int i = 1; i <= 6; i++) {*

• digitalWrite(rows[i - 1], LOW);*

• }*

• clearLeds();*

• // Turn off toggling of pin 11*

• FrequencyTimer2::disable();*

• // Set refresh rate (interrupt timeout period)*

• FrequencyTimer2::setPeriod(2000);*

• // Set interrupt routine to be called*

• FrequencyTimer2::setOnOverflow(display);*
}
void loop()
{

• setPattern(propria[frame]);*

• frame++;*

• if(frame >= 3){*

• frame=0;*

• }*

• delay(2000);*
}
void clearLeds() {

• // Clear display array*

• for (int i = 0; i < 6; i++) {*

• for (int j = 0; j < 6; j++) {*
_ leds*[j] = 0;_
_
}_
_
}_
_
}_
void setPattern(byte p) {
_
for (int i = 0; i < 6; i++) {_
_
for (int j = 0; j < 6; j++) {_
leds_[j] = p[j];
}
}
}
// Interrupt routine*

void display() {
* digitalWrite(cols[col], LOW); // Turn whole previous column off*
* col++;
if (col == 6) {
col = 0;
}
for (int row = 0; row < 6; row++) {
if (leds[col][5 - row] == 1) {
digitalWrite(rows[row], LOW); // Turn on this led*

* }
else {
digitalWrite(rows[row], HIGH); // Turn off this led*

* }
}
digitalWrite(cols[col], HIGH); // Turn whole column on at once (for equal lighting times)
delayMicroseconds(900); // Delay so that on times are longer than off time = brighter leds*

}
And here is the image of my circuit_

we figured out that the lilypad has no capacity to proces all the needed information for this matrix, so we had to come back to use the arduino diecimila

Things like this:-

``````#define A { \
{ 1, 1, 1, 1, 1, 1},  \
{ 1, 1, 1, 1, 1, 1}, \
{ 1, 1, 1, 1, 1, 1}, \
{ 1, 1, 1, 1, 1, 1},  \
{ 1, 1, 1, 1, 1, 1},  \
{ 1, 1, 1, 1, 1, 1}, \
}
``````

Is massively wasteful, you are using bytes when all you need to use are bits. Each one of those lines can be reduced to 1 byte giving you an 8 times saving on memory. That's why you ran out of resource.

``````#define A { \
{ 0x3f},  \
{ 0x3f}, \
{ 0x3f}, \
{ 0x3f},  \
{ 0x3f},  \
{0x3f}, \
}
``````