Hi! I’m a student who doesn’t know much about electronics and I’m working on some Arduino project which uses two Sparkfun Matrix with serial interface (w Backpack).
The first one (LED Matrix - Serial Interface - Red/Green/Blue) works perfectly with this code:
#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 DATAOUT 11//MOSI - DI
#define SPICLOCK 13//sck - SCK
#define SLAVESELECT 10//ss - CS
char image [64] =
{
RED,RED,RED,RED,RED,RED,RED,RED,
GREEN,GREEN,GREEN,GREEN,GREEN,GREEN,GREEN,GREEN,
RED,RED,RED,RED,RED,RED,RED,RED,
GREEN,GREEN,GREEN,GREEN,GREEN,GREEN,GREEN,GREEN,
RED,RED,RED,RED,RED,RED,RED,RED,
GREEN,GREEN,GREEN,GREEN,GREEN,GREEN,GREEN,GREEN,
RED,RED,RED,RED,RED,RED,RED,RED,
GREEN,GREEN,GREEN,GREEN,GREEN,GREEN,GREEN,GREEN
};
void setup()
{
SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1);//Activate SPI HW, Master Mode, diviser Clock par 16
pinMode(DATAOUT, OUTPUT);
pinMode(SPICLOCK,OUTPUT);
pinMode(SLAVESELECT,OUTPUT);
digitalWrite(SLAVESELECT,HIGH);
Serial.begin(9600);
}
void loop()
{
transfer(image);
}
char spi_transfer(volatile char data)
{
SPDR = data;
while (!(SPSR & (1<<SPIF)))
{
};
return SPDR;
}
void transfer(char myData[64]) {
digitalWrite(SLAVESELECT, LOW);
for(int i=0; i<64; i++){
spi_transfer(myData[i]);
}
digitalWrite(SLAVESELECT, HIGH);
delayMicroseconds(500);
}
But the second one (LED Matrix - Serial Interface - Red/Green), doesn’t work at all! For this one I used this code:
#define DATAOUT 11//MOSI - DI
#define SPICLOCK 13//sck - SCK
#define SLAVESELECT 10//ss - CS
char image [64] =
{
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,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
};
void setup()
{
SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1);//Activate SPI HW, Master Mode, diviser Clock par 16
pinMode(DATAOUT, OUTPUT);
pinMode(SPICLOCK,OUTPUT);
pinMode(SLAVESELECT,OUTPUT);
digitalWrite(SLAVESELECT,HIGH);
Serial.begin(9600);
}
void loop()
{
transfer(image);
}
char spi_transfer(volatile char data)
{
SPDR = data;
while (!(SPSR & (1<<SPIF)))
{
};
return SPDR;
}
void transfer(char myData[64]) {
digitalWrite(SLAVESELECT, LOW);
for(int i=0; i<64; i++){
spi_transfer(myData[i]);
}
digitalWrite(SLAVESELECT, HIGH);
delayMicroseconds(500);
}
The thing is, when I first connected the RG Matrix, it displayed a welcoming animation (lines of different colors) and then stopped on an image of a happy looking face, a smiley of sorts. Now it displays only the welcoming animation then goes black.
I would really appreciate any help, it drives me crazy, I wonder if I somehow managed to mess up the firmware…
Then again, I’ve no idea how to re-upload the firmware to the backpack using Arduino
Anyway, I have to mention that I also pressed the RESET button on the Backpack the first time I used it…
If this button resets the firmware I’m totally screwed :?
Anyway, I’d like to know if its somehow broken or it needs a different code.