Matrix Serial Read

skykicker

New member
have this code I have tried to make serial read


Code:
// You must download and install the library from http://fastled.io/
#include <FastLED.h>
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif

#define NUM_STRIPS 44                             // Changed from original for 3 strings
#define NUM_LEDS_PER_STRIP 22                    // Using 63 pixels per string
#define NUM_LEDS NUM_LEDS_PER_STRIP * NUM_STRIPS // Total number of LEDs
#define PIN 8


CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];


Adafruit_NeoMatrix matrix1 = Adafruit_NeoMatrix(NUM_STRIPS, NUM_LEDS_PER_STRIP, PIN,
                             NEO_MATRIX_TOP     + NEO_MATRIX_LEFT +
                             NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
                             NEO_GRB            + NEO_KHZ800);

const uint16_t colors[] = {
    matrix1.Color(255, 0, 0), matrix1.Color(0, 255, 0), matrix1.Color(255, 255, 0), matrix1.Color(0, 0, 255), matrix1.Color(255, 0, 255), matrix1.Color(0, 255, 255), matrix1.Color(255, 255, 255)
};
 

void setup() {
  // Define the speed of the serial port
  Serial.begin(115200);
    matrix1.begin();
  matrix1.setTextWrap(false);

}

void loop() {
  // Set some counter / temporary storage variables
  int cnt;
  unsigned int num_leds;
  unsigned int d1, d2, d3;

  // 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 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') * 100 + (d2 - '0') * 10 + (d3 - '0');
    // ensure the number of pixels does not exceed the number allowed
    if (num_leds > NUM_LEDS) {
      continue;
    }
    /*  ----have commeted this section to try and use matrix only----
        // CODE ADDED - tell FastLED there's 63 PIXEL leds on pin 8, starting at index 0 in the led array
        //this line change for one long string
        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);
        // FastLED.addLeds<WS2811, 8,RGB>(leds, 0, 256);
    */
    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!
    matrix.show(); //hopefully will display
  }
}

from, this code

Code:
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
 
#define PIN 12
 
// MATRIX DECLARATION:
// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
//   NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
//     Position of the FIRST LED in the matrix; pick two, e.g.
//     NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
//   NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
//     rows or in vertical columns, respectively; pick one or the other.
//   NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
//     in the same order, or alternate lines reverse direction; pick one.
//   See example below for these values in action.
// Parameter 5 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
 
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
  NEO_MATRIX_BOTTOM    + NEO_MATRIX_RIGHT +
  NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
  NEO_GRB            + NEO_KHZ800);
 
const uint16_t colors[] = {
  matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(255, 255, 0),matrix.Color(0, 0, 255), matrix.Color(255, 0, 255), matrix.Color(0, 255, 255), matrix.Color(255, 255, 255)};
 
void setup() {
  matrix.begin();
  matrix.setTextWrap(false);
  matrix.setBrightness(5);
  matrix.setTextColor(colors[0]);
}
 
int x    = matrix.width();
int pass = 0;
 
void loop() {
  matrix.fillScreen(0);
  matrix.setCursor(x, 0);
  matrix.print(F("Test"));
 
  if(--x < -30)
{
    x = matrix.width();
 
    if(++pass >= 8) pass = 0;
    matrix.setTextColor(colors[pass]);
  }
  matrix.show();
  delay(30);
}

I just can't figure out the serial read, :mad:

I am going to try and make it for 2 matrices.

I have been trying to research this guess I am not finding the right resources.

I do work about 60 hrs a week with no access to a computer to be able to find this information so any and ALL help will be appreciated.
 
For some reason my arduino max will not control more than 900 pixels thought matrix might make them both work since 1224 pixels. Lowered baud rate and same thing maybe have to use different board.
 
So far I have had to use the norm sorting sketch and then manually hange the elements. First string normal the following reverse the n normal and so on
Seemsto work just was looking for a something that was easier as I want to add a couple more matrix and have faces argue. During Halloween.
 
ok so i have given up on trying to make serial read matrix just adjusted the elements to make it work,
one grid is 44x22 and works with this code
Code:
#include <FastLED.h>
//must put >>968<< as header.  and will have to zig_zag rows manually in vixen.
//#include <Adafruit_GFX.h>
//#include <Adafruit_NeoMatrix.h>
//#include <Adafruit_NeoPixel.h>
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif

//#define NUM_STRIPS 44 // made 44 for colums Changed from original for 3 strings
//#define NUM_LEDS_PER_STRIP 22 // now 22 per string -- Using 63 pixels per string
#define NUM_LEDS 968

CRGB leds[968];

void setup() {
  // Define the speed of the serial port
  Serial.begin(115200);// now 115200 to see if not too fast for amount of leds 230400 work for a minute then stopped
}

void loop() {
  // Set some counter / temporary storage variables
  int cnt;
  unsigned int num_leds;
  unsigned int d1, d2, d3;

  // 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 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') * 100 + (d2 - '0') * 10 + (d3 - '0');
    // ensure the number of pixels does not exceed the number allowed
    if (num_leds > NUM_LEDS) {
      continue;
    }

    // CODE ADDED - tell FastLED there's 50 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 50 PIXEL leds on pin 9, starting at index 63 in the led array
    //FastLED.addLeds<WS2811, 9,RGB>(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);

    // CODE ADDED - tell FastLED there's 50 PIXEL leds on pin 10, starting at index 126 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 50 PIXEL leds on pin 11, starting at index 189 in the led array
    //FastLED.addLeds<WS2811, 11,RGB>(leds, NUM_LEDS_PER_STRIP*3, NUM_LEDS_PER_STRIP);
    // HOPEFULLY THIS WILL WORK FOR THE GRID
    //    FastLED.addLeds<WS2812B, 2, GRB>(leds, 0, 256);
    FastLED.addLeds<WS2812B, 8, GRB>(leds, 0, 968); /* when extra -- NUM_LEDS_PER_STRIP*4-- */
    // Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, 12,
    //  NEO_MATRIX_TOP     + NEO_MATRIX_LEFT +
    //  NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
    //  NEO_GRB            + NEO_KHZ800);
    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!
    //    matrix.show();
  }
}

when I change it to to add the 256 (32x80) grid like this

Code:
#include <FastLED.h>
//must put >>1224<< as header.  and will have to zig_zag rows manually in vixen.
//#include <Adafruit_GFX.h>
//#include <Adafruit_NeoMatrix.h>
//#include <Adafruit_NeoPixel.h>
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif

//#define NUM_STRIPS 44 // made 44 for colums Changed from original for 3 strings
//#define NUM_LEDS_PER_STRIP 22 // now 22 per string -- Using 63 pixels per string
#define NUM_LEDS 1224

CRGB leds[1224];

void setup() {
  // Define the speed of the serial port
  Serial.begin(115200);// now 115200 to see if not too fast for amount of leds 230400 work for a minute then stopped
}

void loop() {
  // Set some counter / temporary storage variables
  int cnt;
  unsigned int num_leds;
  unsigned int d1, d2, d3;

  // 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 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') * 100 + (d2 - '0') * 10 + (d3 - '0');
    // ensure the number of pixels does not exceed the number allowed
    if (num_leds > NUM_LEDS) {
      continue;
    }

    // CODE ADDED - tell FastLED there's 50 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 50 PIXEL leds on pin 9, starting at index 63 in the led array
    //FastLED.addLeds<WS2811, 9,RGB>(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP);

    // CODE ADDED - tell FastLED there's 50 PIXEL leds on pin 10, starting at index 126 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 50 PIXEL leds on pin 11, starting at index 189 in the led array
    //FastLED.addLeds<WS2811, 11,RGB>(leds, NUM_LEDS_PER_STRIP*3, NUM_LEDS_PER_STRIP);
    // HOPEFULLY THIS WILL WORK FOR THE GRID
    //    FastLED.addLeds<WS2812B, 2, GRB>(leds, 0, 256);
    FastLED.addLeds<WS2812B, 8, GRB>(leds, 0, 968); /* when extra -- NUM_LEDS_PER_STRIP*4-- */
    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!
    //    matrix.show();
  }
}

wonder if any one might know what is wrong as i have ready on multiple places that mega can handle 2500 pixels:unsure:
 
This may not be your primary issue but I am curious here .

This accounts for pixels in your code .

CRGB leds[968];

FastLED.addLeds<WS2812B, 8, GRB>(leds, 0, 968); /* when extra -- NUM_LEDS_PER_STRIP*4-- */

Why is this in your code ->
#define NUM_LEDS 1224

to satisfy this ?
if (num_leds > NUM_LEDS) {
continue;
should it be this ?
if (num_leds > leds[]) {
continue;
 
The second code was not updated correctly the two lines should show, guess I copied the wrong one
FastLED.addLeds<WS2812B, 8, GRB>(leds, 0, 968) // for the first 44 x 22 matrix
FastLED.addLeds<WS2812B, 10, GRB>(leds, 968, 256) // for the second 32 x 8 matrix

This worked fine for the other 63 pixel strands. 4 other on 4 different pins
 
The second code was not updated correctly the two lines should show, guess I copied the wrong one
FastLED.addLeds<WS2812B, 8, GRB>(leds, 0, 968) // for the first 44 x 22 matrix
FastLED.addLeds<WS2812B, 10, GRB>(leds, 968, 256) // for the second 32 x 8 matrix

This worked fine for the other 63 pixel strands. 4 other on 4 different pins

To word properly, for each instantiation you need to add ->

FastLED.addLeds<WS2812B, 8, GRB>(leds, 0, 968) // for the first 44 x 22 matrix

FastLED.addLeds<WS2812B, 10, GRB>(leds1, 968, 256) // for the second 32 x 8 matrix

CRGB leds[968];
CRGB leds1[xxx];
 
original multi pin code

Here is the original code I am trying to modify

Code:
// header in vixen must be >>###<<  ### will be your total number of leds


// You must download and install the library from http://fastled.io/ 
#include <FastLED.h>

#define NUM_STRIPS 4                             // Changed from original for 3 strings
#define NUM_LEDS_PER_STRIP 63                    // Using 63 pixels per string
#define NUM_LEDS NUM_LEDS_PER_STRIP * NUM_STRIPS // Total number of LEDs

CRGB leds[NUM_STRIPS * NUM_LEDS_PER_STRIP];


void setup() {
    // Define the speed of the serial port
Serial.begin(115200);
}

void loop() {
    // Set some counter / temporary storage variables
int cnt;
unsigned int num_leds;
unsigned int d1, d2, d3;

    // 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 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')*100+(d2-'0')*10+(d3-'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
    //this line change for one long string
 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);
    // FastLED.addLeds<WS2811, 8,RGB>(leds, 0, 256);

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 works great if all strings are the same size.
 
If this works great ,I would suggest building your prop to suit what the firmware will support .
It is much easier to configure the simple pixel wiring layout then it is write or re-write complex code .
 
Found out when I put header to >>999<< some of the second matrix work, any more and neither work guess just have to have only the 44x22 matrix. Unless there is something else I am missing.
 
Wow I can't believe I didn't think of that. Its been years since I was programming. That's why I love these forums. If you forget something there most likely be someone to help. Thanks so much. After you mentioned it I was like "DUH". That makes so much sense the other code only looked for three didgets.


Sent from my SM-F926U using Tapatalk
 
Great news both grids work great.
fa83d1af7bc113eea7cf8059e989a893.jpg


Sent from my SM-F926U using Tapatalk
 
Will post the final soon. When I get back to the computer. I do have one with the matrix that will keep repeating what ever line you like with put sequencer. Both will be posted tomorrow.

Sent from my SM-F926U using Tapatalk
 
here is the final code that finally worked :biggrin2:

Code:
// 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
#define matrix_b 256                    // 8*32
#define NUM_LEDS matrix_a + matrix_b    // 968+256=1224

CRGB leds[matrix_a + matrix_b];         // 968+256=1224


void setup() {
  // Define the speed of the serial port
  Serial.begin(115200);   //115200 worked now I'm checking 230400
}

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!
  }
}

matrix code for non-serial, "just displays message"

Code:
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>

#define PIN 3

// MATRIX DECLARATION:
// Parameter 1 = width of NeoPixel matrix
// Parameter 2 = height of matrix
// Parameter 3 = pin number (most are valid)
// Parameter 4 = matrix layout flags, add together as needed:
//   NEO_MATRIX_TOP, NEO_MATRIX_BOTTOM, NEO_MATRIX_LEFT, NEO_MATRIX_RIGHT:
//     Position of the FIRST LED in the matrix; pick two, e.g.
//     NEO_MATRIX_TOP + NEO_MATRIX_LEFT for the top-left corner.
//   NEO_MATRIX_ROWS, NEO_MATRIX_COLUMNS: LEDs are arranged in horizontal
//     rows or in vertical columns, respectively; pick one or the other.
//   NEO_MATRIX_PROGRESSIVE, NEO_MATRIX_ZIGZAG: all rows/columns proceed
//     in the same order, or alternate lines reverse direction; pick one.
//   See example below for these values in action.
// Parameter 5 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)

Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(44, 22, PIN,
  NEO_MATRIX_BOTTOM    + NEO_MATRIX_RIGHT +
  NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
  NEO_GRB            + NEO_KHZ800);

const uint16_t colors[] = {
  matrix.Color(255, 0, 0), matrix.Color(0, 255, 0), matrix.Color(255, 255, 0),matrix.Color(0, 0, 255), matrix.Color(255, 0, 255), matrix.Color(0, 255, 255), matrix.Color(255, 255, 255)};

void setup() {
  matrix.begin();
  matrix.setTextWrap(false);  //"true" if multi-lines
  matrix.setBrightness(5);
  matrix.setTextColor(colors[0]);
}

int x    = matrix.width();
int pass = 0;

void loop() {
  matrix.fillScreen(0);    //Turn off all the LEDs
  matrix.setCursor(x, 0);
  matrix.print(F("Just Display This Message"));  //inside the "can be anything you want"

  if( --x < -30 ) {
    x = matrix.width();

    if(++pass >= 6) pass = 0;
    matrix.setTextColor(colors[pass]);
  }
  matrix.show();
  delay(30);
}


Again thanks to everyone for their help
 
Back
Top