Hello.
I just got my serial led matrix ( http://www.sparkfun.com/commerce/produc … cts_id=760 ) and I’m trying to get it to work.
I successfully connected it and displayed stuff on it, but when it comes to animation/regular-display-updating, something strange happens.
Here is the code, it’s an example that I just modified to see the problem better.
#define CHIPSELECT 10//ss
#define SPICLOCK 13//sck
#define DATAOUT 11//MOSI
#define DATAIN 12//MISO
int num = 1;
char spi_transfer(volatile char data)
{
SPDR = data; // Start the transmission
while (!(SPSR & (1<<SPIF))) // Wait the end of the transmission
{
};
}
void setup()
{
byte clr;
pinMode(DATAOUT,OUTPUT);
pinMode(SPICLOCK,OUTPUT);
pinMode(CHIPSELECT,OUTPUT);
digitalWrite(CHIPSELECT,HIGH); //disable device
SPCR = B01010001; //SPI Registers
SPSR = SPSR & B11111110; //make sure the speed is 125KHz
clr=SPSR;
clr=SPDR;
}
void loop()
{
digitalWrite(CHIPSELECT,LOW);
delayMicroseconds(500);
num++;
if(num > 64){num = 0;}
for (int i=0;i<8;i++) for (int j=0;j<8;j++)
{
if( num > j+(i*8) ){
spi_transfer(char(255));
}else{
spi_transfer(char(0));
}
}
digitalWrite(CHIPSELECT,HIGH);
delayMicroseconds(500);
delay(1000);
}
So the problem is : normally this code should light up one more led on the display every second.
That’s not what happens, I get 4 more leds every 4 seconds ( or 8 more every 8 seconds, delay seems to add with uptime ).
Depending on the value of the delay this number changes too, but I never get the display to change EVERY time I tell it to.
It always jumps a few spi transmitions.
pin 13, used as SPIclock in the code, is also a led on the arduino, and I see it blinking every 1 second, so the arduino is doing it’s job. ( but maybe not well )
I have read all forum threads about this device and have found no similar problem, or clue.
Does someone have any idea what the problem might be ?
Thanks a lot !