This code works great for the Arduino mega 2560.
// header in vixen must be >>####<< #### will be your total number of leds , 1224 for these 2 matrix, >>1224<<
// Many thanks to all who helped at doityourselfchristmas.com
// You must download and install the library from http://fastled.io/
#include <FastLED.h>
#define matrix_a 968 // 22*44 Pin 8
#define matrix_b 968 // 8*32 Pin 10
#define NUM_LEDS matrix_a + matrix_b // 968+256=1224 or 968*2=1936
CRGB leds[matrix_a + matrix_b]; // 1224 or 1936
void setup() {
// Define the speed of the serial port
Serial.begin(1048576); //115200 worked now I'm checking (slow 230400),(ok 921600),1048576
}
void loop() {
// Set some counter / temporary storage variables
int cnt;
unsigned int num_leds;
unsigned int d1, d2, d3, d4;
// Begin an endless loop to receive and process serial data
for (;;) {
// Set a counter to 0. This couter keeps track of the pixel colors received.
cnt = 0;
//Begin waiting for the header to be received on the serial bus
//1st character
while (!Serial.available());
if (Serial.read() != '>') {
continue;
}
//second character
while (!Serial.available());
if (Serial.read() != '>') {
continue;
}
//get the first digit from the serial bus for the number of pixels to be used
while (!Serial.available());
d1 = Serial.read();
//get the second digit from the serial bus for the number of pixels to be used
while (!Serial.available());
d2 = Serial.read();
//get the third digit from the serial bus for the number of pixels to be used
while (!Serial.available());
d3 = Serial.read();
//get the forth digit from the serial bus for the number of pixels to be used
while (!Serial.available());
d4 = Serial.read();
//get the end of the header
while (!Serial.available());
if (Serial.read() != '<') {
continue;
}
while (!Serial.available());
if (Serial.read() != '<') {
continue;
}
// calculate the number of pixels based on the characters provided in the header digits
num_leds = (d1 - '0') * 1000 + (d2 - '0') * 100 + (d3 - '0') * 10 + (d4 - '0');
// ensure the number of pixels does not exceed the number allowed
if (num_leds > NUM_LEDS) {
continue;
}
// CODE ADDED - tell FastLED there's 63 PIXEL leds on pin 8, starting at index 0 in the led array
// FastLED.addLeds<WS2811, 8, RGB>(leds, 0, NUM_LEDS_PER_STRIP);
// CODE ADDED - tell FastLED there's 63 PIXEL leds on pin 9, starting at index 64 in the led array
// FastLED.addLeds<WS2811, 9, RGB>(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);
// CODE ADDED - tell FastLED there's 63 PIXEL leds on pin 10, starting at index 127 in the led array
// FastLED.addLeds<WS2811, 10, RGB>(leds, NUM_LEDS_PER_STRIP * 2, NUM_LEDS_PER_STRIP);
// CODE ADDED - tell FastLED there's 63 PIXEL leds on pin 11, starting at index 190 in the led array
// FastLED.addLeds<WS2811, 11, RGB>(leds, NUM_LEDS_PER_STRIP * 3, NUM_LEDS_PER_STRIP);
// CODE ADDED - tell FastLED there's 968 PIXEL leds on pin 8, starting at index 0 in the led array
FastLED.addLeds<WS2811, 8, GRB>(leds, 0, matrix_a);
// CODE ADDED - tell FastLED there's 256 PIXEL leds on pin 10, starting at index 968 in the led array
FastLED.addLeds<WS2811, 10, GRB>(leds, matrix_a, matrix_b);
do {
while (!Serial.available());
leds[cnt].r = Serial.read();
while (!Serial.available());
leds[cnt].g = Serial.read();
while (!Serial.available());
leds[cnt++].b = Serial.read();
}
while (--num_leds); // Tell the FastLED Library it is time to update the strip of pixels
FastLED.show(); // WOO HOO... We are all done and are ready to start over again!
}
}
This is so that Vixen Lights (very need lighting program, same concept as xlights just different interface.) can control the pixel grids that I have made.
This works great on the arduino as stated. however, since the mega 2560 is somewhat limited, it is a bit laggy, does not do all the changes at the correct time. I have read that the ESP32 has enough computing power to run these small grids without lagging so I wanted to try it. However, cannot seem to get the ESP32-wroom to realize that it should be doing something with the signals that it is receiving. Since I read that the language is the same I thought it would work however, this code does not do anything with the ESP32 even if i change the pins. I realize that I do not really have the time to completely figure this out is the is what would be called a hobby as only have a couple of hours a week to figure it out. So if someone could point me in the right direction to get it to work, like mainly the differences between the two and what I am missing. There is obviously something needed to have it realize that it needs to read the information being sent to it and then send that information to the pixel so the pixel knows what and when it is supposed to do something. this code is compilation of years of searching the internet to find one that works. Many thanks to the original creators not sure if it still mentions them, and I do not recall now who they all where. Until I find them again think one of them was Brian L .
Sorry for the ramble just trying to get all the information here.
Again thanks for any help in advance.