RPI-RGB-LED-Matrix SKU:EP-0043
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
Package includes
- 1x RPI-RGB-LED-Matrix module
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] = {0xEF,0xFF,0xFF,0x04}; static uint8_t i = 0; wiringPiSetup(); wiringPiSPISetup(0,500000); while(1){ data[0] = 0xF7; data[2] = 0xFF; data[1] = 0xFF; data[3] = 0x01; wiringPiSPIDataRW(0,data,sizeof(data)); delay(2); data[0] = 0xF3; data[2] = 0xFF; data[1] = 0xFF; data[3] = 0x02; wiringPiSPIDataRW(0,data,sizeof(data)); delay(2); } }
3.Compile it.
sudo gcc -o matrix matrix.c -lwiringPi
4.Run it.
sudo ./matrix
5.You will see it ligths up.
Other Examples
- 1. Static Heart Sign
#include <stdio.h> #include <stdio.h> #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:
#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); } }
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); }