Hi Programmers,
This code displays a text message on an LED matrix when published to the subscribed MQTT topic then reverts to displaying the current time.
I want the last text message sent
to display whenever IO5 is taken low.
I believe I need to call the function described below but cannot get the code to compile.
How do I call this function below ?
void display_message(String message) {
// Displays a message on the matrix
for ( int i = 0 ; i < width * message.length() + matrix.width() - spacer; i++ ) {
int letter = i / width;
int x = (matrix.width() - 1) - i % width;
int y = (matrix.height() - 8) / 2; // center the text vertically
while ( x + width - spacer >= 0 && letter >= 0 ) {
if ( letter < message.length() ) {
matrix.drawChar(x, y, message[letter], HIGH, LOW, 1); // HIGH LOW means foreground ON, background off, reverse to invert the image
}
letter--;
x -= width;
}
matrix.write(); // Send bitmap to display
delay(wait / 2);
}
}
I want to call the above function when IO5 goes low ..
if (digitalRead(5) == LOW) { // D1 Mini input D1 = IO5
display_message(String message); // Not working
}
This gives me a a compiler error saying
expected primary-expression before 'message'
Can someone show me the correct syntax and explain why the usual command I use ie function_name(); does not work here.
Full code attached in zip file.
Arduino_Forum.zip (3.7 KB)
Cheers