Good morning,
I've just bought an Arduino Uno and a sparkfun RG matrix: SparkFun LED Matrix - Serial Interface (Red/Green) - COM-00759 - SparkFun Electronics
And i have read as many forum posts as possible but i just can't get the thing to work.
I'm pretty sure the wiring is correct (for uno): 10 to CS, 11 to MISO and 13 to SCLK (and power obviously)
When i power on i get the lines scroll across in green red and orange. Then i get nothing, no matter what i try.
I can see the led on pin 13 flashing away so i think stuff is moving over.
Could this be the firmware on the backpack? i see the RGB has updated firmware, but no one ever seems to answer anyone's questions about the RG one on sparkfun.
Just as a bit of background i attach a couple of sketches i've tried:
// Simple program to test using the Arduino with the RGB Matrix
// & Backpack from Sparkfun. Code is a combination of Heather Dewey-Hagborg,
// Arduino Forum user: Little-Scale, and // Daniel Hirschmann. Enjoy!
//
// The Backpack requires 125Khz SPI, which is the slowest rate
// at which the Arduino's hardware SPI bus can communicate at.
//
// We need to send SPI to the backpack in the following steps:
// 1) Activate ChipSelect;
// 2) Wait 500microseconds;
// 3) Transfer 64bytes @ 125KHz (1 byte for each RGB LED in the matrix);
// 4) De-activate ChipSelect;
// 5) Wait 500microseconds
// Repeat however often you like!#define CHIPSELECT 10//ss
#define SPICLOCK 13//sck
#define DATAOUT 11//MOSI / DI
#define DATAIN 12//MISO / DOint data[] =
{0,0,0,0,0,0,0,0,
0,0,1,1,0,1,1,0,
0,1,0,0,1,0,0,1,
0,1,0,0,0,0,0,1,
0,0,1,0,0,0,1,0,
0,0,0,1,0,1,0,0,
0,0,0,0,1,0,0,0,
0,0,0,0,0,0,0,0
};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 deviceSPCR = B01010001; //SPI Registers
SPSR = SPSR & B11111110; //make sure the speed is 125KHz/*
SPCR bits:
7: SPIEE - enables SPI interrupt when high
6: SPE - enable SPI bus when high
5: DORD - LSB first when high, MSB first when low
4: MSTR - arduino is in master mode when high, slave when low
3: CPOL - data clock idle when high if 1, idle when low if 0
2: CPHA - data on falling edge of clock when high, rising edge when low
1: SPR1 - set speed of SPI bus
0: SPR0 - set speed of SPI bus (00 is fastest @ 4MHz, 11 is slowest @ 250KHz)
*/clr=SPSR;
clr=SPDR;
delay(10);
}void loop()
{
delay(100);
int index = 0;
digitalWrite(CHIPSELECT,LOW); // enable the ChipSelect on the backpack
delayMicroseconds(500);
for (int i=0;i<8;i++) for (int j=0;j<8;j++)
{
spi_transfer(data[index]);
index++;
}
digitalWrite(CHIPSELECT,HIGH); // disable the ChipSelect on the backpack
delayMicroseconds(500);
}
And this one, nicked from justin's bike light code from here http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1234580222/15
/* define constants */
#define DATAOUT 11 //MOSI
#define DATAIN 12 //MISO // NOT USED
#define SPICLOCK 13 //sck
#define SLAVESELECT 10 //ss
#define WAIT 50 // min delay between frames.#define BLACK 0
#define RED 1
#define GREEN 2
#define ORANGE 3char out_buffer[64]; // output buffer for led matrix
// here are the bitmaps that the various modes use.
byte BACKGROUND[] = {
B11111111,
B11111111,
B11111111,
B11111111,
B11111111,
B11111111,
B11111111,
B11111111
};byte X [] = {
B11100111,
B01000010,
B00100100,
B00011000,
B00011000,
B00100100,
B01000010,
B11100111
};/*
Write image to output buffer.
Should be preceeded by a call to fill_buffer()
/
void write_buffer(){
digitalWrite(SLAVESELECT,LOW); // enable
delay(5);
for(int i = 0; i < 64; i++){
shiftOut(DATAOUT, SPICLOCK, MSBFIRST, out_buffer);*
- } *
- digitalWrite(SLAVESELECT,HIGH); // disable device*
- delay(5);*
}
_/* _
Fill a buffer usting bitmap (data) in the specified color
Bit locations with a 0 are untouched so layers can be added consecutivly
A call to fill_buffer() should preceed write_buffer.
The buffer is filled first to avoid timing errors involved in non-sequential writes
*/
void fill_buffer(byte* data, int color){- byte bit;*
- for (int i = 0; i < 8; i++)*
- {*
- for(int j = 0; j < 8; j++){*
- bit = data[7 - i] >> j & B0000001;*
- if(bit){*
out_buffer[i * 8 + j] = color % 4;- }*
- }*
- }*
}
/*
Initialize pins and modes, calibrate.
*/
void setup(){
_ Serial.begin(9600);_- pinMode(DATAOUT, OUTPUT);*
- pinMode(DATAIN, INPUT); // NOT USED*
- pinMode(SPICLOCK,OUTPUT);*
- pinMode(SLAVESELECT,OUTPUT);*
- digitalWrite(SLAVESELECT,HIGH); //disable device*
}
/*
Get current mode, display current mode, pause.
*/
void loop(){- fill_buffer(BACKGROUND, BLACK);*
- fill_buffer(X, RED);*
- write_buffer();*
- delay(WAIT);*
}
[/quote]
Cheers for anything you can help me with, i just want simple colours to show so i can move on to the next stage.
Ryk