Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Deutsch / SparkFun LED-Matrix on: February 26, 2009, 10:36:10 am
Hi,

ich würde gern mit einer 8x8 RG-LED-Matrix (die von SparkFun mit SPI-Backpack) Bilder und Lauftexte darstellen. Einen Inhalt einmal darstellen klappt auch schon.

Ich habe mich an den Code aus dem Forum gehalten.
Code:
// 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,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 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++;                  
  }
  digitalWrite(CHIPSELECT,HIGH); // disable the ChipSelect on the backpack
  delayMicroseconds(500);
}
Was mir aber einfach nicht gelingen will, ist die Schleife in der Art zu erweitern um nach einer einem delay ein weiteres Bild zu zeigen.
Ist das denn der richtige Ansatz? Kann mir jemand ein wenig auf die Spünge helfen?

Gruß
2  Forum 2005-2010 (read only) / Interfacing / Re: SparkFun LED-Matrix 8x8 on: September 01, 2010, 09:09:44 am
--------------         -------------------------
Arduino      |         |       LED Matrix SparkFun (COM-00759)
           3-1 |-------|  SCK
           1-1 |-------|  MOSI
           0-1 |-------|  CS
                 |         |
          +5V |-------|  +5V
          GND |-------|  GND
--------------          ------------------------

LED-Matrix: http://www.sparkfun.com/commerce/product_info.php?products_id=759

datasheet: http://www.sparkfun.com/datasheets/Components/matrix_backpack.pdf
3  Forum 2005-2010 (read only) / Interfacing / Re: SparkFun LED-Matrix 8x8 on: March 16, 2009, 03:25:33 am
Hi Justin,

thanks for your reply. Your code example brings a nice eye-catching look to the led-matrix. It redraws one image with different colors. What i want to do is to draw an image, sleep 1 second, than draw an other image, sleep 1 second and so on. Do you know how to realize this?
I also had a look at your bike-turn-signal project but the code looks to complex to me. I think i just need a few lines code. no input pins et cetera.

Regards
Johnas
4  Forum 2005-2010 (read only) / Interfacing / SparkFun LED-Matrix 8x8 on: March 03, 2009, 11:46:44 am
Hi,

I would like to use the 8x8 RG-LED Matrix with SPI-Backpack from SparkFun to display letters or pics with the aeduino. I play with the code from here:
Code:
// 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,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 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++;                  
  }
  digitalWrite(CHIPSELECT,HIGH); // disable the ChipSelect on the backpack
  delayMicroseconds(500);
}

Thats working for me. Now i would like to display another picture e.g.

Code:
int data[] =
{0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,
0,0,0,0,1,0,0,0,
1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1
};

after a delay but i dont find a way to modify the code to do that. can somebody help me?

regards
johnas
Pages: [1]