LED matrix problem with button click ON to display new message.

I am a beginner in Arduino programming, I have this code below attached:

I have an app that I can control LED matrixes (i used MIT app inventor to make my app) on my phone so when I click on the button ON (in my code MODE 5) I wanna display the message “POWER ON” on my LED matrix and I want that message to disappear after its shown on the matrix and display a new message for example (“LED matrix”) right away so my problem here is how can I display the second message right away on the matrix and that it won t disappear so that it can repeat over and over again.

Thank you, for your time.

Dot_matrix_code_zip.ino (13.7 KB)

Welcome to the forums. I think the easiest way would be to refactor your code. I got lost inside all your if/else clauses. Read this tutorial: Serial Input Basics - updated to learn a better way to receive messages. This way, you only react if a new message arrives. Then, read this tutorial: several things at the same time to learn how to break you code up into functions that do just a small part of what you need to do. Think of a state machine. Finally, you might need to study the example BlinkWithoutDelay (File->examples->02.Digital->Blink Without Delay) to learn how to keep track of elapsed time. You note the time you start something and then track how long it has been (for example, your mode 5 initial message) and then when enough time has elapsed, you transition to the next message....

Good Luck!

thank you for your help and time blh64, I will try to learn more about it more with your links and refactor the code.

Since you are using Strings, you should check out my Taming Arduino Strings tutorial
You also have some char's so you could look at my SafeString tutorial which lets you work with char like they where Arduino Strings, i.e. safely.
For doing multiple things as once check out my Multitasking in Arduino tutorial,
For timers say to flash up your start up message check out my How to write Timers and Delays in Arduino tutorial.

You seem to be reading the input from a Serially connect bluetooth module.
Adding a '\n' to indicate the end of the command would be helpful then you could use this non-blocking code to read the input. The code readString() you are using at the moment blocks the rest of the loop.

// stopC is the char to stop at
// returns true when get stopC and input contains the input up to then
// else return false
bool readStrUntil(char stopC, String& input) {
  while (Serial.available()) {
    char c = Serial.read();
    if (c == stopC) {
      return true;
    // else
    input += c; // good for >1000 char lines on UNO
  return false;

As another completely different approach, you could use my (paid) pfodApp instead of the MIT app creator.
This example project uses Adafruit BLE Uart module
There is a free pfodDesigner app that lets you build custom menus that are loaded into your Arduino rather then in the phone. The same pfodApp works with all the menus you build.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.