Saturday, September 13, 2008

Wired Panel

I went out and bought more gator clips and wrote up some code so I can give my cork board led panel a test drive.

AND IT WORKS!
Cork 5


8x8 Red LED Matrix driven by Arduino. from Andrew Parnell on Vimeo.


For those of you interested in the code, see the comments section.

1 comment:

Andrew S. Parnell said...

#ARDUINO CODE AS FOLLOWS
#Written by Andrew S. Parnell

const int numPatterns = 14;

int anPins[8] = {18,17,16,15,14,2,3,4};
int cathPins[8] = {5, 6, 7, 8, 9, 10, 11, 12};

byte patterns[numPatterns][8][8] = {{ \
{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,1}
},{ \
{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,1,1}, \
{0,0,0,0,0,0,1,1}
},{ \
{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,1,1,1}, \
{0,0,0,0,0,1,1,1}, \
{0,0,0,0,0,1,1,1}
},{ \
{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,1,1,1,1},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,1,1,1,0,0,0}
},{ \
{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,0,0,0,0,0}, \
{1,1,1,0,0,0,0,0}, \
{1,1,1,0,0,0,0,0}, \
{1,1,1,0,0,0,0,0}, \
{1,1,1,0,0,0,0,0}
},{ \
{1,1,1,1,1,1,1,1}, \
{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,0,0,0,0,0}, \
{1,0,0,0,0,0,0,0}, \
{1,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}
}};

void setup() {
for (int i = 0; i < 8; i++) {
pinMode(anPins[i], OUTPUT);
pinMode(cathPins[i], OUTPUT);
}
for (int i = 0; i < 8; i++) {
digitalWrite(anPins[i], LOW);
digitalWrite(cathPins[i], HIGH);
}
}

void loop() {
for(int i = 0; i < numPatterns; i++) {
pattern(patterns[i], 500);
}
}

void pattern(byte pat[8][8],unsigned long inc)
{
unsigned long T = millis() + inc;
while(millis() < T) {
for (int i = 0; i < 8; i++) {
digitalWrite(cathPins[i], LOW);
for (int j = 0; j < 8; j++) {
digitalWrite(anPins[j], pat[i][j]);
}
blank();
digitalWrite(cathPins[i], HIGH);
}
}
}

void blank() {
for (int i = 0; i < 8; i++) {
digitalWrite(anPins[i], LOW);
}
}