# How to send message to 4 Sparkfun 8x8 LED Matrix Backpack

**URL:** <https://community.sparkfun.com/t/how-to-send-message-to-4-sparkfun-8x8-led-matrix-backpack/12531>\
**Category:** MicroMod\
**Tags:** avr-atmel\
**Created:** [September 10, 2009, 10:25pm UTC](https://community.sparkfun.com/t/how-to-send-message-to-4-sparkfun-8x8-led-matrix-backpack/12531 "2009-09-10T22:25:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elim](https://avatars.discourse-cdn.com/v4/letter/e/a9adbd/32.png) [@elim](https://community.sparkfun.com/u/elim)\
**Post date:** [September 10, 2009, 10:25pm UTC](https://community.sparkfun.com/t/how-to-send-message-to-4-sparkfun-8x8-led-matrix-backpack/12531/1 "2009-09-10T22:25:10Z")

</div>

Hi,

I tried to chain four 8x8 LED matrix with backpack I got from Sparkfun. I already configure each of them. But I don’t have a code to test.

Does anyone has simple code examples I can run test. I’d like to have effect like the message would go over from the

This is the code I use, but only works for one LED backpack, if I connect 3 more, they’d only display the same image with the first one.

// 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 / DO

int data =

{0,0,0,0,0,0,0,0,

0,0,0xE0,0xE0,0xE0,0,0,0,

0,0xE0,0,0xE0,0xE0,0,0,0,

0,0,0xE0,0xE0,0xE0,0xE0,0,0,

0,0,0xE0,0xE0,0xE0,0xE0,0,0,

0,0,0xE0,0xE0,0xE0,0xE0,0,0,

0,0,0xE0,0xE0,0xE0,0xE0,0,0,

0,0,0,0xE0,0xE0,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 device

SPCR = 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++;

// There are only 8 colours available to the matrix with the

// backpack, so this will present 1 colour per column on the matrix

}

digitalWrite(CHIPSELECT,HIGH); // disable the ChipSelect on the backpack

delayMicroseconds(500);

}

Any suggestions is appreciated! Thanks!!

Elim

---

<div class="post-metadata">

**Author:** ![Rob182](https://avatars.discourse-cdn.com/v4/letter/r/a698b9/32.png) [@Rob182](https://community.sparkfun.com/u/Rob182)\
**Post date:** [October 18, 2010, 1:05am UTC](https://community.sparkfun.com/t/how-to-send-message-to-4-sparkfun-8x8-led-matrix-backpack/12531/2 "2010-10-18T01:05:26Z")

</div>

I send the code to the arduino, the TX and RX lights blink

talked to sparkfun about it, even though it was a moth out of warranty,

Dec 4, 2009. 9:21 PM seandogue says:

How to Install the Arduino to the Lithium Backpack by Severino Pong with 8x8 Led Matrix on Arduino by bsoares.

[[[u]how to treat depression[/u]](http://howtodealwithdepression.net.ph/)]([http://howtodealwithdepression.net.ph/](http://howtodealwithdepression.net.ph/))
