Arduino+LED Matrix w Backpack (HELP!)

Your source for all things Atmel.

Moderator: phalanx

Post Reply
renard
Posts: 5
Joined: Sat Jun 13, 2009 6:47 pm

Arduino+LED Matrix w Backpack (HELP!)

Post by renard » Sat Jun 13, 2009 8:12 pm

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:

Code: Select all

#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:

Code: Select all

#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.

wyojustin
Posts: 28
Joined: Sat Jul 18, 2009 10:47 am

Try the first code again.

Post by wyojustin » Sat Jul 18, 2009 12:38 pm

First off pressing reset will not harm backpack nor the code on it, so your ok there. The fact that you still see the start up screen is a good sign.

Now, have you tried running the first code again? If it works, great that means you have a bug in the new code somewhere. If not, recheck all of the connections.

Just remember, it feels so good when it stops hurting.

Justin

renard
Posts: 5
Joined: Sat Jun 13, 2009 6:47 pm

Post by renard » Sat Jul 18, 2009 3:46 pm

First of all, thank you for your answer, I really appreciate it.

Anyway, I've tried everything I could, the new code, the old code and still nothing.

I keep thinking something's wrong with the backpack.

DougMac
Posts: 1
Joined: Sat Nov 28, 2009 11:30 pm
Location: Annapolis MD

Help Problems with the Sparkfun demo code

Post by DougMac » Sat Nov 28, 2009 11:55 pm

Unlike most of the users here I am using the RGB Backpack with Olimex P28 board as opposed to the Ardunio board. It is the basic atmega328 board with the ISP loader connector.
I use the AVR Studio 4 with the gcc compiler. the blinker test works fine but I can not get the Sparkfun 'RGB_Sample_Interface_code' to work at all.
Has anybody ever had this code work. It downloads ok but no messages appear on the RGB matrix. The SPI port is wired to the SPI Input connector as follows
atmega328 pin 17 MOSI ---- backpack pin 5 MISO
pin 16 SS ---- " pin 4 CS
" pin 19 SCK ---- " pin 3 SCK
board VCC ---- " pin 1,2 VCC
board GND ---- " pin 6 GND

The display powers up and goes thru the colors but never seems to get any of the 'SPARKFUN ...." message.
I have loaded the board, then power down the Olimex board and disconnect the ISP dongle. Then power it back up and their is still no message
The compile optimization is set to 0 or non
Confused ???

Post Reply