Hi guys, complete noob here regarding arduino, I've been getting into this world since last monday, and trying to learn by doing small things. Please excuse my errors and lack of knowledge.
So I have 2 WS2812b LED Matrix connected to an arduino UNO R3 and a HC-05 BT module used to send data to the arduino
My first attempt was to have two independent scrolling texts, one on each matrix, which I was able to do it defining each used pin for each matrix and naming the second one matrix2:
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif
#define PIN 5
#define SECPIN 6
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, PIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
Adafruit_NeoMatrix matrix2 = Adafruit_NeoMatrix(32, 8, SECPIN,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
const uint16_t colors[] = {
matrix.Color(0, 0, 255), matrix.Color(0, 0, 255), matrix.Color(0, 0, 255)
};
void setup() {
matrix.begin();
matrix.setTextWrap(false);
matrix.setBrightness(6);
matrix.setTextColor(colors[0]);
matrix2.begin();
matrix2.setTextWrap(false);
matrix2.setBrightness(6);
matrix2.setTextColor(colors[0]);
}
int x = matrix.width();
int z = matrix.width();
int pass = 0;
void loop() {
matrix.fillScreen(0);
matrix.setCursor(x, 0);
matrix.print(F("TEXT MATRIX 1"));
if (--x < -64) {
x = matrix.width();
if (++pass >= 3) pass = 0;
matrix.setTextColor(colors[pass]);
}
matrix.show();
delay(50);
matrix2.fillScreen(0);
matrix2.setCursor(z, 0);
matrix2.print(F("TEXT MATRIX 2"));
if (--z < -64) {
z = matrix2.width();
if (++pass >= 2) pass = 0;
matrix2.setTextColor(colors[pass]);
}
matrix2.show();
delay(25);
}
So now I wanted to change the text via bluetooth, wasn't really getting nowhere, because every tutorial seems to be using MAX72XX instead of WS2812b panels for this. Nevertheless, finally made it work. And now is where I'm stuck, I need to have again both matrix, one with the fixed scrolling text, and the second matrix I want to be able to change it via bluetooth.
So in the same way I mix the codes for having text sent to each matrix through each pin, I'm trying to make it work now with this code:
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#ifndef PSTR
#define PSTR // Make Arduino Due happy
#endif
#define PIN 5
#define SECPIN 6
#define NUMPIXELS 256
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(32, 8, 5, // Matrix with editable text via BT
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
Adafruit_NeoMatrix matrix2 = Adafruit_NeoMatrix(32, 8, 6, // Matrix with non editable text via BT
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_GRB + NEO_KHZ800);
String text = "EDIT MESSAGE VIA BT"; //Default text to be printed on the LED matrix when it's powered on
int brightness = 10;
const uint16_t colors[] = {
matrix.Color(0, 0, 255), matrix.Color(0, 0, 255), matrix.Color(0, 0, 255)
};
int string_length = 0;
static byte byteRead = 0;
bool print_text = true;
bool print_off = false;
void setup() {
Serial.begin(38400);
matrix.begin(); //This line should start Matrix 1
matrix.setTextWrap(false);
matrix.setBrightness(20);
matrix.setTextColor(colors[0]);
matrix2.begin(); //This line should start Matrix 2
matrix2.setTextWrap(false);
matrix2.setBrightness(6);
matrix2.setTextColor(colors[0]);
}
int x = matrix.width();
int z = matrix.width();
int pass = 0;
void loop()
{
if (Serial.available() > 0)
{
byteRead = Serial.read(); //Read data from the BT module
if (byteRead == 'T') //If we receive a "T", then we gen into text scroll mode
{
text = Serial.readString(); //Store the bluetooth received text
print_text = true;
}
if (byteRead == 'B') //If we receive a "B", then we change brightness to the received value
{
String Received = Serial.readString();
int brightness = (int(Received[0]) - 48) * 10;
if (brightness == 0)
{
brightness = 100;
}
brightness = constrain(brightness, 0, 100);
matrix.setBrightness(brightness);
matrix2.setBrightness(brightness);
Serial.println(brightness);
}
}//end of serial read
if (print_text && !print_off)
{
string_length = text.length();
matrix.fillScreen(0);
matrix.setCursor(x, 0);
matrix.print(text);
if (--x < -(string_length * 6)) {
x = matrix.width();
if (++pass >= 3) pass = 0;
matrix.setTextColor(colors[pass]);
}
matrix.show();
delay(60);
matrix2.fillScreen(0);
matrix2.setCursor(z, 0);
matrix2.print(F("NON EDITABLE TEXT"));
if (--z< -(string_length * 6)) {
z = matrix2.width();
if (++pass >= 2) pass = 0;
matrix2.setTextColor(colors[pass]);
}
matrix2.show();
delay(60);
}//End of print text
}//end of void loop
With this I can change using and app and bluetooth, the text on the matrix I need to, but cannot make the matrix2 show the "non editable text". I have one matrix with text and matrix2 completely off
I've been really trying to search online, but haven't found much help about this. I'm sure I'm doing something wrong but I can't figure it out, maybe one of you guys can slap me in the back of the head and point me to the right direction.

