Hey I have some code for grapping data sent thrrough the arduino from a web cam to a LED matrix. heres a little about the matrix which is serial code "COM-00760";
"The device maintains a single 64 byte buffer which represents each position in the matrix. When CS is asserted (low) the device begins reading data from the SPI input and writing it sequentially to the 64 byte buffer. Simultaneously the device will output the old buffer data on the MISO line. Hence, to display an image on the matrix a set of 64 bytes must be sequentially transferred to the backpack while keeping the CS pin low (this process is slightly different for a daisy-chained system).
By default, the backpack recognizes up to 255 individual colors. The 64 bytes transferred to the backpack represent the desired color of each LED. The first 3 bits of each byte represent the Red brightness level for that LED; the second 3 bits represent the Green brightness level while the last 2 bits represent the Blue brightness level. Below is a table which illustrates how to construct your color value. "
I am using the following code on the board which is only lighting up four leds which respond to movement by turning on and off and changing colour. The original matrix which the code sent data to, appeared to be just red Leds with a home made pcb backpack. ![]()
int CLOCK = 12;
int LATCH = 13;
int DATA = 11;
byte matrix[8];
byte head;
int state = 0;
void setup() {
pinMode(CLOCK, OUTPUT);
pinMode(LATCH, OUTPUT);
pinMode(DATA, OUTPUT);
digitalWrite(CLOCK, LOW);
digitalWrite(LATCH, LOW);
digitalWrite(DATA, LOW);
initLED();
clearLED();
Serial.begin(9600);
head = (byte) 0x55;
}
void loop() {
if (Serial.available()>0) {
int input = Serial.read();
switch (state) {
case 0:
if (input==head) {
state = 1;
}
break;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
matrix[state-1] = (byte) input;
state++;
break;
case 8:
matrix[state-1] = (byte) input;
state = 0;
refreshLED();
break;
}
}
}
void ledOut(int n) {
digitalWrite(LATCH, LOW);
shiftOut(DATA, CLOCK, MSBFIRST, (n>>8));
shiftOut(DATA, CLOCK, MSBFIRST, (n));
digitalWrite(LATCH, HIGH);
delay(1);
digitalWrite(LATCH, LOW);
}
void initLED() {
ledOut(0x0B07);
ledOut(0x0A0C);
ledOut(0x0900);
ledOut(0x0C01);
}
void clearLED() {
for (int i=0;i<8;i++) {
matrix[i] = 0x00;
}
refreshLED();
}
void refreshLED() {
int n1, n2, n3;
for (int i=0;i<8;i++) {
n1 = i+1;
n2 = matrix[i];
n3 = (n1<<8)+n2;
ledOut(n3);
}
}
void updateLED(int i, int j, boolean b) {
int t = 1;
int n = 0;
int m = 0;
if (j==0) {
m = 7;
}
else {
m = j-1;
}
n = t<
if (b) {
matrix[i] = n | matrix[i];
}
else {
n = ~n;
matrix[i] = n & matrix[i];
}
}