Recently I bought the following matrix: https://learn.adafruit.com/32x16-32x32-rgb-led-matrix/overview
I own an Arduino Uno for those who are interested.
I got the 32x32 variant and I am very happy with it. I managed to connect all the wires correctly and get the examples of the library working.
The problem I am facing right now is I can't get it to work properly for a personal project of mine. Somehow I am unable to use the serial functions and the matrix library functions in one project.
Currently my project looks like this:
My Arduino is connected like this:
And the code I wrote is:
#include <gamma.h>
#include <RGBmatrixPanel.h>
#include <Adafruit_GFX.h>
#include <gfxfont.h>
#define CLK 8
#define OE 9
#define LAT 10
#define A A0
#define B A1
#define C A2
#define D A3
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);
String incomingCommand = "";
void setup() {
Serial.begin(9600);
matrix.begin();
matrix.fillRect(0, 0, 32, 32, matrix.Color333(0, 0, 0));
}
void loop() {
if (Serial.available() > 0) {
int incomingByte = Serial.read();
char receivedChar = (char) incomingByte;
incomingCommand += receivedChar;
}
if (incomingCommand.indexOf('#') > - 1 && incomingCommand.indexOf('%') > - 1) {
String rawCommand = incomingCommand.substring(incomingCommand.indexOf('#'), incomingCommand.indexOf('%') + 1);
rawCommand = rawCommand.substring(1, rawCommand.length() - 1);
Serial.print("Following command received: ");
Serial.println(rawCommand);
if (rawCommand == "turnledon") {
matrix.drawPixel(0, 0, matrix.Color333(7, 7, 7));
}
incomingCommand = "";
rawCommand = "";
}
}
The idea is that a command gets sent from the serial monitor. Based on the command one led on the matrix will turn on. An example of a future command will look similar to this: "#drawPixel_X1_Y2%", hence the part that checks on "#" and "&".
The problem is that the functionality of the serial monitor isn't working with line 14 and 48 of the code. As soon as I remove those lines, the serial monitor works perfectly and I can receive and write to the serial monitor. I have no idea what is causing this.
I was wondering if someone ever faced a similar problem or knows what I am doing wrong right now.
Thank you in advance!
char
array.