RPI-RGB-LED-Matrix SKU:EP-0075

From 52Pi Wiki
Jump to: navigation, search

RPI-RGB-LED-Matrix

Description

RPI-RGB-LED-Matrix is base on 74HC595 chip and it's a 8x8 matrix that you can make a small toy with it.
It communicates with your development board or your chip with SPI protocol, it's very easy to setup and use.
You can use arduino or raspberry Pi, even STC89C51 chip to driving it.
You can use it to do a lot of interesting things, such as musical backdrop, music spectrum analyzer , and even in your bicycle taillights.


Feature

  • Based on 74HC595 chip support
  • Support SPI protocol
  • Low power consumption
  • RGB three-color combination can be a lot of bright colors

Presentation

Matrix1.jpg
Matrix2.jpg
Matrix3.jpg
Matrix4.jpg



Package includes

  • 1x RPI-RGB-LED-Matrix module

How to wire it up

Raspberry Pi 8x8 RGB Matrix Arduino
5V Vcc 5v
GPIO 11 CLK Pin 13
GPIO 8 CE Pin 10
GPIO 10 MOSI Pin 11
GND GND GND

How to use it

  • 1. After power on and login to system. you can open a terminal and edit /boot/config.txt file to enable SPI function.

sudo vim.tiny /boot/config.txt

   device_tree=bcm2710-rpi-3-b.dtb
   dtparam=spi=on
  • 2.Edit a file named it matrix.c and input following paragraph:

sudo vim.tiny matrix.c

#include <stdio.h>
#include <wiringPi.h>
#include <wiringPiSPI.h>
#include <stdint.h>

#define RED_DATA 0
#define BLUE_DATA 1
#define GREEN_DATA 2

int main(void)
{
  static uint8_t data[4] = {0x0,0x0,0x0,0x0};
  
  wiringPiSetup();
  wiringPiSPISetup(0,500000);
  while(1)
     {
         static uint8_t heart[8] = {0x00, 0x66, 0xFF, 0xFF, 0xFF, 0x7E, 0x3C, 0x18};             // this is a array of heart
         int j;
         int x=2;
    for ( j=0;j<8;j++)
        {
          data[0] = ~heart[j];
          data[2] = 0xFF;
          data[1] = 0xFF;
          data[3] = 0x01 << j ;
          wiringPiSPIDataRW(0,data,sizeof(data));              // send data to SPI channel 0, and the length of the data
          delay(x);
        };
    };
}

  • 3.Compile it.

sudo gcc -o matrix matrix.c -lwiringPi

  • 4.Run it.

sudo ./matrix

  • 5.You will see it ligths up.

Other Examples

There are some pictures here:

Matrix5.jpg
Matrix6.jpg
Matrix7.jpg



  • 1. Static Heart Sign

#include <stdio.h>
#include <wiringPi.h>
#include <wiringPiSPI.h>
#include <stdint.h>

#define RED_DATA 0          //define the red data source 
#define BLUE_DATA 1         //define the blue data source
#define GREEN_DATA 2    // define the green data source 

int main(void)
{
  static uint8_t data[4] = {0x0,0x0,0x0,0x0};                  // initialize RGB data source 
  static uint8_t i = 0;                                                       

  wiringPiSetup();                                // initialize wiringPi 
  wiringPiSPISetup(0,500000);           // initialize SPI  information, 0 is channel 0, 500000 is clock rate.
  while(1){                         
    int j;
    int x = 2;
    static uint8_t heart[8] = {0x00, 0x66, 0xFF, 0xFF, 0xFF, 0x7E, 0x3C, 0x18};             // this is a array of heart
    for ( j=0;j<8;j++)
{
          data[0] = ~heart[j];
          data[2] = 0xFF;
          data[1] = 0xFF;
          data[3] = 0x01 << j ;
          wiringPiSPIDataRW(0,data,sizeof(data));              // send data to SPI channel 0, and the length of the data
          delay(x);
   }
  }
}


  • 2. heart beating:

All you need to do is copy following codes to a file named heart.c , and save it, and then compile it.
sudo vim.tiny heart.c


#include <stdio.h>
#include <wiringPi.h>
#include <wiringPiSPI.h>
#include <stdint.h>

#define RED_DATA 0
#define BLUE_DATA 1
#define GREEN_DATA 2

int main(void)
{
  static uint8_t data[4] = {0x0,0x0,0x0,0x0};
  static uint8_t i = 0;

  wiringPiSetup();
  wiringPiSPISetup(0,500000);

void heartbig()
   {
    int j;
    int x = 2;
    static uint8_t heart[8] = {0x00, 0x66, 0xFF, 0xFF, 0xFF, 0x7E, 0x3C, 0x18};
    for ( j=0;j<8;j++)
                {
          data[0] = ~heart[j];
          data[2] = 0xFF;
          data[1] = 0xFF;
          data[3] = 0x01 << j ;
          wiringPiSPIDataRW(0,data,sizeof(data));
          delay(x);
                }
};

void heartsmall()
   {
    int j;
    int x = 2;
    static uint8_t heart[8] = {0x00, 0x00, 0x24, 0x7E, 0x7E, 0x3C, 0x18, 0x00};
    for ( j=0;j<8;j++)
                {
          data[0] = ~heart[j];
          data[2] = 0xFF;
          data[1] = 0xFF;
          data[3] = 0x01 << j ;
          wiringPiSPIDataRW(0,data,sizeof(data));
          delay(x);
                }
};

void matrixoff()
{
 int j;
 int x = 2;
    static uint8_t heart[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    for ( j=0;j<8;j++)
     {
          data[0] = ~heart[j];
          data[2] = 0xFF;
          data[1] = 0xFF;
          data[3] = 0x01 << j ;
          wiringPiSPIDataRW(0,data,sizeof(data));
          delay(x);
       }
}

while(1){
     int m = 10;
     for ( m=10; m>0; m--)
        {
         heartbig();
         };
         matrixoff();
        delay(100);
     for ( m=10; m>0; m--)
         {
         heartsmall();
         };
         matrixoff();
         delay(100);
    }
}


  • 2. Compile it and run it.

sudo gcc -o heart heart.c -lwiringPi
sudo ./heart


You will see a view like this:
Rpimatrix.gif


How to use Arduino to light up 8x8 matrix

  • 1. Open an Arduino IDE and paste this code and upload to your Arduino board.
#include <SPI.h>

static uint8_t data[4] = {0x0, 0x0, 0x0, 0x0};
static uint8_t i = 1;
const int CE = 10;

void heartbig()
{
  int j;
  int x = 2;
  static uint8_t heart[8] = {0x00, 0x66, 0xFF, 0xFF, 0xFF, 0x7E, 0x3C, 0x18};
  for ( j = 0; j < 8; j++)
  {
    data[0] = ~heart[j];
    data[2] = 0xFF;
    data[1] = 0xFF;
    data[3] = 0x01 << j ;
    digitalWrite(CE, LOW);
    SPI.transfer(data[0]);
    SPI.transfer(data[2]);
    SPI.transfer(data[1]);
    SPI.transfer(data[3]);
    digitalWrite(CE, HIGH);
    delay(x);
  }
};

void heartsmall()
{
  int j;
  int x = 2;
  static uint8_t heart[8] = {0x00, 0x00, 0x24, 0x7E, 0x7E, 0x3C, 0x18, 0x00};
  for ( j = 0; j < 8; j++)
  {
    data[0] = ~heart[j];
    data[2] = 0xFF;
    data[1] = 0xFF;
    data[3] = 0x01 << j ;
    digitalWrite(CE, LOW);
    SPI.transfer(data[0]);
    SPI.transfer(data[2]);
    SPI.transfer(data[1]);
    SPI.transfer(data[3]);
    digitalWrite(CE, HIGH);
    delay(x);
  }
};

void matrixoff()
{
  int j;
  int x = 2;
  static uint8_t heart[8] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
  for ( j = 0; j < 8; j++)
  {
    data[0] = ~heart[j];
    data[2] = 0xFF;
    data[1] = 0xFF;
    data[3] = 0x01 << j ;
    digitalWrite(CE, LOW);
    SPI.transfer(data[0]);
    SPI.transfer(data[2]);
    SPI.transfer(data[1]);
    SPI.transfer(data[3]);
    digitalWrite(CE, HIGH);
    delay(x);
  }
};

void setup() {
  pinMode(CE, OUTPUT);
  SPI.begin();
}

void loop()
{
  int m = 10;
  for ( m = 10; m > 0; m--) {
    heartbig();
  };
  matrixoff();
  delay(100);
  for ( m = 10; m > 0; m--) {
    heartsmall();
  };
  matrixoff();
  delay(100);
}


Then, You will see this:

Arduino.gif


Application Senario

  • There is a link below shown that we made an E-Bike with this 8*8 RGB LED matrix during Maker Fair.

[Voice-Prompt-Electric-Bike | https://www.instructables.com/id/Voice-Prompt-Electric-Bike/ ]