I purchased a Reland Sun 8x8 Full Color RGB LED matrix. It came with no information and I can't find much online about how to mix the colors. It uses SPI protocol and has 5 pins (VCC, GND, SCK, MOSI and CE) which I connected to the appropriate Arduino Uno pins - SCK to 13, MOSI to 11, and CE to 10 and of course the power pins.
I found code that allows me to create a pattern in red, or green or blue only but I want to try to create patterns in other colors.
I was able to figure out how to create some different colors, but not how to make a particular pattern in a different color. For example, I have the code for an arrow, but I can only have it show up in red, green or blue and if I try to make other colors I get random lights. I can show you my code, but is there some library that makes it easier for this type of matrix?'
I've tried several libraries and none of them work with this matrix or at least I can't figure out how to make it work. I want to be able to control each pixel like the neopixel library allows but that doesn't work with this device?
Does anyone have any advice other than "buy a different device?" (which I am willing to do as this only cost me $11)
The code below will display a red heart. When I copy the line ~heart[j]; to another color like data[1] I get really weird things happen. It doesn't mix the colors like I would expect it to.
//Go here to find hex codes for pictures (sprites) https://gurgleapps.com/tools/matrix#tp-color
#include <SPI.h> // include the head file to enable the library.
static uint8_t data[4] = {0x00, 0x0, 0x0, 0x0}; // defined a data matrix
static uint8_t i = 1; // defined a variable vector
const int CE = 10; // defined the CE function pin
void heartbig() // defined a function called "heart big".
{
int j;
int x = 2;
static uint8_t heart[8] = {0x00, 0x66, 0xFF, 0xFF, 0xFF, 0x7E, 0x3C, 0x18}; // you need to calculate which led should be light up by this array, it defined line by line on your matrix, for example , 0x00 means the led of the first line is off, and the 0x66 means the second line's first led will go off and the fourth led will go off and fifth led will go off and eight led will go off. others will turn on....and so on.
for ( j = 0; j < 8; j++)
{
data[0] = ~heart[j]; // color red
data[2] = 0xFF; // color blue
data[1] = 0xFF; // color green
data[3] = 0x01 << j ; // display the data on matrix.
digitalWrite(CE, LOW); // when CE is low, it begin to receive data.
SPI.transfer(data[0]); //transfer data[0] to the matrix(red)
SPI.transfer(data[2]); //transfer data[2] to the matrix(green)
SPI.transfer(data[1]); // transfer data[1] to the matrix(blue)
SPI.transfer(data[3]); // tansfer data[3] to the matrix( scanning and display the data on matrix)
digitalWrite(CE, HIGH); // when CE is High, means that matrix begin to display the array's information to the matrix.
delay(x); // a little bit delay, let the led light up and stay for a while so that it looks like it brightness.
}
};
void setup() {
pinMode(CE, OUTPUT); //initialized the pin's mode.
SPI.begin(); // start spi function
}
void loop() //defined a loop function
{
int m = 10;
for ( m = 10; m > 0; m--) { // make a for loop to let the data displayed on the matrix.
heartbig();
};
}
type or paste code here