I’m working on a project where part of it uses an 8X8 led matrix. I’m using one I bought from Adafruit.

The pattern is on a video here (I had to use a piece of paper so the leds didn’t cause distortion in the image): http://youtu.be/FGIAMo4Cw_c

I was wondering if anyone could give me any ideas on how I could shorten the code. Right now it uses many For loops but I imagine there must be a way to do it in a very short amount of code. This is just one pattern of many and I hope to use whatever advice I get and apply it towards them all.

Here’s my code so far (separated out so it’s just this matrix):

```
#include <Wire.h>
#include "Adafruit_LEDBackpack.h"
#include "Adafruit_GFX.h"
Adafruit_8x8matrix matrix = Adafruit_8x8matrix();
void setup() {
Serial.begin(9600);
Serial.println("8x8 Test");
matrix.setBrightness(0);
matrix.setRotation(1);
matrix.begin(0x70); // pass in the address
}
void loop() {
matrix.clear();
for (int x=0; x<=7; x++) {
matrix.drawPixel(0,x, LED_ON);
matrix.writeDisplay();
delay(100);
}
for (int x=1; x<=7; x++) {
matrix.drawPixel(x,7, LED_ON);
matrix.writeDisplay();
delay(100);
}
for (int x=6; x>=0; x--) {
matrix.drawPixel(7,x, LED_ON);
matrix.writeDisplay();
delay(100);
}
for (int x=6; x>=1; x--) {
matrix.drawPixel(x,0, LED_ON);
matrix.writeDisplay();
delay(100);
}
//
for (int x=1; x<=6; x++) {
matrix.drawPixel(1,x, LED_ON);
matrix.writeDisplay();
delay(100);
}
for (int x=2; x<=5; x++) {
matrix.drawPixel(x,6, LED_ON);
matrix.writeDisplay();
delay(100);
}
for (int x=6; x>=1; x--) {
matrix.drawPixel(6,x, LED_ON);
matrix.writeDisplay();
delay(100);
}
for (int x=5; x>=2; x--) {
matrix.drawPixel(x,1, LED_ON);
matrix.writeDisplay();
delay(100);
}
//
for (int x=2; x<=5; x++) {
matrix.drawPixel(2,x, LED_ON);
matrix.writeDisplay();
delay(100);
}
for (int x=3; x<=4; x++) {
matrix.drawPixel(x,5, LED_ON);
matrix.writeDisplay();
delay(100);
}
for (int x=5; x>=2; x--) {
matrix.drawPixel(5,x, LED_ON);
matrix.writeDisplay();
delay(100);
}
for (int x=4; x>=3; x--) {
matrix.drawPixel(x,2, LED_ON);
matrix.writeDisplay();
delay(100);
}
matrix.drawPixel(3,3, LED_ON);
matrix.writeDisplay();
delay(100);
matrix.drawPixel(3,4, LED_ON);
matrix.writeDisplay();
delay(100);
matrix.drawPixel(4,4, LED_ON);
matrix.writeDisplay();
delay(100);
matrix.drawPixel(4,3, LED_ON);
matrix.writeDisplay();
delay(500);
}
```

Any advice would be appreciated.