Hello everyone, I did not find the answer I was looking for, but if you happen to know a link would be just fine. I am trying to alter the sample code for the 8x8 Spark Fun LED MATRIX (RGB) to animate it, but I seem to be having trouble. Below is the code that I have and I am not sure what elements need to be changed. Thanks so much for any help.
// Writing to the RGB Serial Backpack Matrix from SparkFun Electronics
// by Ryan Owens
// Copyright SparkFun Electronics
//Define the "Normal" Colors
#define BLACK 0
#define RED 0xE0
#define GREEN 0x1C
#define BLUE 0x03
#define ORANGE RED|GREEN
#define MAGENTA RED|BLUE
#define TEAL BLUE|GREEN
#define WHITE (RED|GREEN|BLUE)-0xA0
//Define the SPI Pin Numbers
#define DATAOUT 11//MOSI
#define DATAIN 12//MISO
#define SPICLOCK 13//sck
#define SLAVESELECT 10//ss
//Define the variables we'll need later in the program
char color_buffer [64];
void setup()
{
//SPI Bus setup
SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1); //Enable SPI HW, Master Mode, divide clock by 16 //SPI Bus setup
//Set the pin modes for the RGB matrix
pinMode(DATAOUT, OUTPUT);
pinMode(DATAIN, INPUT);
pinMode(SPICLOCK,OUTPUT);
pinMode(SLAVESELECT,OUTPUT);
//Make sure the RGB matrix is deactivated
digitalWrite(SLAVESELECT,HIGH);
}
void loop()
{
//Load colors into the first row color buffer array.
//This will be the array of colors sent to the RGB matrix.
color_buffer[10]=MAGENTA;
color_buffer[11]=MAGENTA;
color_buffer[12]=MAGENTA;
color_buffer[13]=MAGENTA;
color_buffer[17]=MAGENTA;
color_buffer[18]=MAGENTA;
color_buffer[19]=MAGENTA;
color_buffer[20]=MAGENTA;
color_buffer[21]=MAGENTA;
color_buffer[22]=MAGENTA;
color_buffer[25]=MAGENTA;
color_buffer[26]=MAGENTA;
color_buffer[27]=MAGENTA;
color_buffer[28]=MAGENTA;
color_buffer[29]=MAGENTA;
color_buffer[30]=MAGENTA;
color_buffer[33]=MAGENTA;
color_buffer[34]=MAGENTA;
color_buffer[35]=MAGENTA;
color_buffer[36]=MAGENTA;
color_buffer[37]=MAGENTA;
color_buffer[38]=MAGENTA;
color_buffer[41]=MAGENTA;
color_buffer[42]=MAGENTA;
color_buffer[43]=MAGENTA;
color_buffer[44]=MAGENTA;
color_buffer[45]=MAGENTA;
color_buffer[46]=MAGENTA;
color_buffer[50]=MAGENTA;
color_buffer[51]=MAGENTA;
color_buffer[52]=MAGENTA;
color_buffer[53]=MAGENTA;
//Activate the RGB Matrix
digitalWrite(SLAVESELECT, LOW);
//Send the color buffer to the RGB Matrix
for(int LED=0; LED<64; LED++){
spi_transfer(color_buffer[LED]);
}
//Deactivate the RGB matrix.
digitalWrite(SLAVESELECT, HIGH);
while(1);
//delay(100); // allow some time for the Serial data to be sent
}
//Use this command to send a single color value to the RGB matrix.
//NOTE: You must send 64 color values to the RGB matrix before it displays an image!
char spi_transfer(volatile char data)
{
SPDR = data; // Start the transmission
while (!(SPSR & (1<<SPIF))) // Wait for the end of the transmission
{
};
return SPDR; // return the received byte
}