How to print Parola new message on Serial Monitor "after" pressing send

Hi,
Sketch below is for Parola scrolling to MAX7219; works fine. I can type new message in Serial Monitor and press send it begins to scroll the new message.

Could someone advise what lines of code to add or change in my sketch so that:

when I press Send on the Serial Monitor,

the new message is also "printed out on the serial monitor"

Reason being, if my MAX7219 is not visible to me (that is, I'm not looking at it) I'd like to see on the serial monitor what message is currently scrolling.
Thank You

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

// set to 1 if we are implementing the user interface pot, switch, etc
#define USE_UI_CONTROL 0

#if USE_UI_CONTROL
#include <MD_UISwitch.h>
#endif

// Turn on debug statements to the serial output
#define DEBUG 0

#if DEBUG
#define PRINT(s, x) { Serial.print(F(s)); Serial.print(x); }
#define PRINTS(x) Serial.print(F(x))
#define PRINTX(x) Serial.println(x, HEX)
#else
#define PRINT(s, x)
#define PRINTS(x)
#define PRINTX(x)
#endif

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 11
#define CLK_PIN   13  // or SCK    52  13
#define DATA_PIN  11  // or MOSIB  51  11
#define CS_PIN    10  // or SS     53  10

// HARDWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// SOFTWARE SPI
//MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

// Scrolling parameters
#if USE_UI_CONTROL
const uint8_t SPEED_IN = A5;
const uint8_t DIRECTION_SET = 8;  // change the effect
const uint8_t INVERT_SET = 9;     // change the invert

const uint8_t SPEED_DEADBAND = 5;
#endif // USE_UI_CONTROL

uint8_t scrollSpeed = 35;    // default frame delay value
textEffect_t scrollEffect = PA_SCROLL_LEFT;
textPosition_t scrollAlign = PA_LEFT;
uint16_t scrollPause = 2000; // in milliseconds

// Global message buffers shared by Serial and Scrolling functions
#define	BUF_SIZE	75
char curMessage[BUF_SIZE] = { "" };
char newMessage[BUF_SIZE] = { "Hello World" };
bool newMessageAvailable = true;

#if USE_UI_CONTROL

MD_UISwitch_Digital uiDirection(DIRECTION_SET);
MD_UISwitch_Digital uiInvert(INVERT_SET);

void doUI(void)
{
  // set the speed if it has changed
  {
    int16_t speed = map(analogRead(SPEED_IN), 0, 1023, 10, 150);

    if ((speed >= ((int16_t)P.getSpeed() + SPEED_DEADBAND)) ||
        (speed <= ((int16_t)P.getSpeed() - SPEED_DEADBAND)))
    {
      P.setSpeed(speed);
      scrollSpeed = speed;
      PRINT("\nChanged speed to ", P.getSpeed());
    }
  }

  if (uiDirection.read() == MD_UISwitch::KEY_PRESS) // SCROLL DIRECTION
  {
    PRINTS("\nChanging scroll direction");
    scrollEffect = (scrollEffect == PA_SCROLL_LEFT ? PA_SCROLL_RIGHT : PA_SCROLL_LEFT);
    P.setTextEffect(scrollEffect, scrollEffect);
    P.displayClear();
    P.displayReset();
  }

  if (uiInvert.read() == MD_UISwitch::KEY_PRESS)  // INVERT MODE
  {
    PRINTS("\nChanging invert mode");
    P.setInvert(!P.getInvert());
  }
}
#endif // USE_UI_CONTROL

void readSerial(void)
{
  static char *cp = newMessage;

  while (Serial.available())
  {
    *cp = (char)Serial.read();
    if ((*cp == '\n') || (cp - newMessage >= BUF_SIZE - 2)) // end of message character or full buffer
    {
      *cp = '\0'; // end the string
      // restart the index for next filling spree and flag we have a message waiting
      cp = newMessage;
      newMessageAvailable = true;
    }
    else  // move char pointer to next position
      cp++;
  }
}

void setup()
{
  Serial.begin(57600);
  Serial.print("\n[Parola Scrolling Display]\n use Newline in Serial Monitor\nType a message for the scrolling display");

#if USE_UI_CONTROL
  uiDirection.begin();
  uiInvert.begin();
  pinMode(SPEED_IN, INPUT);

  doUI();
#endif // USE_UI_CONTROL

  P.begin();
  P.displayText(curMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
}

void loop()
{
#if USE_UI_CONTROL
  doUI();
#endif // USE_UI_CONTROL

  if (P.displayAnimate())
  {
    if (newMessageAvailable)
    {
      strcpy(curMessage, newMessage);
      newMessageAvailable = false;
    }
    P.displayReset();
  }
  readSerial();
}

Try something like this:

void loop()
{
#if USE_UI_CONTROL
  doUI();
#endif // USE_UI_CONTROL

  if (P.displayAnimate())
  {
    if (newMessageAvailable)
    {
      strcpy(curMessage, newMessage);
      Serial.print(&curMessage);      // Suggested by Railroader
      newMessageAvailable = false;
    }
    P.displayReset();
  }
  readSerial();
}

Thanks, I tried the suggested void loop and got the following error (this is just the tail end of the error message….it was like 2 or 3 pages long)

exit status 1
no matching function for call to 'print(char (*)[75])'

I'm still googling and youtubing to try to find what code might work. Again, thanks.

You will not likely find a syntax answer that way.
Use Arduino/reference to get the correct syntax. Maybe

      Serial.print(*curMessage);      // Suggested by Railroader

Is correct....

Thanks, I will research the syntax like you suggest.
I tried your void loop as you
originally typed &curMessage
and then I tried typing it again with your
current post *curMessage
and still no luck.

Let's wait for a helper being more comfortable with matters like this to step in.

Hi Railroader,
Your SerialPrint suggestion was the beginning of my solution. Thank You.

For the past evening and today I researched SerialPrint syntax (not easy since sites don't all tell the syntax whole story...was a combo of websites).

So I did the following:

part 1. figured out the syntax to have the Serial Monitor print a string...group of inputted words

part 2. then i had to figure out WHICH parameter to put inside the Serial.print function.......(eg. char, newMessage, cp, etc etc) but being a Newbie, and not knowing, I had to do trial & error......however

part 3. I had to concurrently figure out WHERE in the sketch do I put the Serial.print code.....but being a Newbie, I had to do trial & error on that too. This meant selecting ONE parameter from part 2 and then putting it in ONE spot in the sketch and run it. This is what took all the time.....lots and lots of edited sketches.

part 4. Once I got the Serial.print function to actually print the new message on the Serial Monitor, then I had to figure out how to make it a separate line.

OK for those in the know, I guess this was a 15 second problem....but took me a lot longer.

Bottom line:
See my Final sketch below and
scroll down to where I show //////////////// ADDED ADDED

These two simple lines of code (one was actually added, whereas the second line was an edit) SOLVED my problem.

Wanted to SHARE THIS with the Arduino Community for those that have the same question.

Besides the Sketch, I attached 2 photos.....one showing the response in the Serial Monitor and the other is the actual Scroll box doing it's thing.

//
//   I modified this to have the "new message" show on the SERIAL MONITOR....AFTER pressing SEND
//   I can now see what's scrolling if I'm not looking at the scroll matrix or it's out of view
//   I can now see if I made any typing errors when typing-in the new message
//   See where I show ////////////////  ADDED
//
//
// Use the Parola library to scroll text on the display
//
// Demonstrates the use of the scrolling function to display text received
// from the serial interface
//
// User can enter text on the serial monitor and this will display as a
// scrolling message on the display.
// Speed for the display is controlled by a pot on SPEED_IN analog in.
// Scrolling direction is controlled by a switch on DIRECTION_SET digital in.
// Invert ON/OFF is set by a switch on INVERT_SET digital in.
//
// UISwitch library can be found at https://github.com/MajicDesigns/MD_UISwitch
// MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
//

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

// set to 1 if we are implementing the user interface pot, switch, etc
#define USE_UI_CONTROL 0

#if USE_UI_CONTROL
#include <MD_UISwitch.h>
#endif

// Turn on debug statements to the serial output
#define DEBUG 0

#if DEBUG
#define PRINT(s, x) { Serial.print(F(s)); Serial.print(x); }
#define PRINTS(x) Serial.print(F(x))
#define PRINTX(x) Serial.println(x, HEX)
#else
#define PRINT(s, x)
#define PRINTS(x)
#define PRINTX(x)
#endif

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 11
#define CLK_PIN   13  // or SCK    52  13
#define DATA_PIN  11  // or MOSIB  51  11
#define CS_PIN    10  // or SS     53  10

// HARDWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// SOFTWARE SPI
//MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

// Scrolling parameters
#if USE_UI_CONTROL
const uint8_t SPEED_IN = A5;
const uint8_t DIRECTION_SET = 8;  // change the effect
const uint8_t INVERT_SET = 9;     // change the invert

const uint8_t SPEED_DEADBAND = 5;
#endif // USE_UI_CONTROL

uint8_t scrollSpeed = 35;    // default frame delay value
textEffect_t scrollEffect = PA_SCROLL_LEFT;
textPosition_t scrollAlign = PA_LEFT;
uint16_t scrollPause = 2000; // in milliseconds

// Global message buffers shared by Serial and Scrolling functions
#define	BUF_SIZE	75
char curMessage[BUF_SIZE] = { "" };
char newMessage[BUF_SIZE] = { "Hello Everyone" };
bool newMessageAvailable = true;

#if USE_UI_CONTROL

MD_UISwitch_Digital uiDirection(DIRECTION_SET);
MD_UISwitch_Digital uiInvert(INVERT_SET);

void doUI(void)
{
  // set the speed if it has changed
  {
    int16_t speed = map(analogRead(SPEED_IN), 0, 1023, 10, 150);

    if ((speed >= ((int16_t)P.getSpeed() + SPEED_DEADBAND)) ||
        (speed <= ((int16_t)P.getSpeed() - SPEED_DEADBAND)))
    {
      P.setSpeed(speed);
      scrollSpeed = speed;
      PRINT("\nChanged speed to ", P.getSpeed());
    }
  }

  if (uiDirection.read() == MD_UISwitch::KEY_PRESS) // SCROLL DIRECTION
  {
    PRINTS("\nChanging scroll direction");
    scrollEffect = (scrollEffect == PA_SCROLL_LEFT ? PA_SCROLL_RIGHT : PA_SCROLL_LEFT);
    P.setTextEffect(scrollEffect, scrollEffect);
    P.displayClear();
    P.displayReset();
  }

  if (uiInvert.read() == MD_UISwitch::KEY_PRESS)  // INVERT MODE
  {
    PRINTS("\nChanging invert mode");
    P.setInvert(!P.getInvert());
  }
}
#endif // USE_UI_CONTROL

void readSerial(void)
{
  static char *cp = newMessage;

  while (Serial.available())
  {
    *cp = (char)Serial.read();
      
![image_6487327|666x500](upload://o21csfxANw4iCHxjUvoQy0yfbej.jpeg)

         Serial.print(*cp);           /////////////////////////ADDED  ADDED  ADDED this serial print line at left

    if ((*cp == '\n') || (cp - newMessage >= BUF_SIZE - 2)) // end of message character or full buffer
    {
      *cp = '\0'; // end the string
      // restart the index for next filling spree and flag we have a message waiting
      cp = newMessage;
      newMessageAvailable = true;

    }
    else  // move char pointer to next position
      cp++;
  }
}

void setup()
{
  
  Serial.begin(57600);
  
  ////////////////////////////////  ADDED   ADDED  an Edit to the line BELOW  
  ////////////////////////////////  \n  was put after the words  ....scrolling display"
  
  Serial.print("\n[Parola Scrolling Display]\n MY REMINDER with Serial Monitor settings choose Newline and correct baud rate\nType a message for the scrolling display\n ");

#if USE_UI_CONTROL
  uiDirection.begin();
  uiInvert.begin();
  pinMode(SPEED_IN, INPUT);

  doUI();
#endif // USE_UI_CONTROL

  P.begin();
  P.displayText(curMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
}

void loop()
{

#if USE_UI_CONTROL
  doUI();
#endif // USE_UI_CONTROL
            
  if (P.displayAnimate())
  {
    if (newMessageAvailable)
    {
      strcpy(curMessage, newMessage);
      newMessageAvailable = false;
    }
    P.displayReset();
  }
  readSerial();

}

Uploading: IMG_3649.jpg...


Sorry...the Serial Monitor PHOTO above was not the latest. I had elaborated on the line that says MY REMINDER.
The code is the latest and this Serial Monitor photo is the latest too.

Regarding serial monitor printing it works well using Serial.println there's a Cr+Lf, \n, added making the next Serial.print arrive on the next line.
Regarding displays, things are different...

Okey. You are printing the characters one by one upon arrival.
So the bending and twisting made You reach the target. That's the goal.

That's a construction I would never have guessed. It looks like not compiling to me....

Thanks.
Like they say, Mission Accomplished

I just re-looked at your post #10 . That line:

was the upload message saying my Photo was in the process of being uploaded .

Now I understand: my post #8 with the solution, was NOT ABLE TO UPLOAD a photo and there was a circle in the center going round and round.
Not wanting to lose all I wrote I pressed SEND and the post was sent with that crazy jpg line embedded in the middle of my sketch. That's when I sent the next post #9 with ONLY PHOTOS since they wouldn't upload properly in my solution post #8

....now this is really getting silly.
In Post 12 i wrote the crazy line out just as shown in my sketch above. And guess what.....instead of showing the crazy line "as shown in the sketch", the posting syntax or rules, actually printed the PHOTO in my post 12. So that explains the line you mentioned.
If I feel comfortable about it, I may do just one more post with the same words as my Post 8 and uploading the two proper photos AND tagging that post as the SOLUTION


(disregard previous posts....this post summarizes the final Solution....proper sketch, with correct corresponding photos)
Hi Railroader,
Your SerialPrint suggestion was the beginning of my solution. Thank You.

For the past evening and today I researched SerialPrint syntax (not easy since sites don't all tell the syntax whole story...was a combo of websites).

So I did the following:

part 1. figured out the syntax to have the Serial Monitor print a string...group of inputted words

part 2. then i had to figure out WHICH parameter to put inside the Serial.print function.......(eg. char, newMessage, cp, etc etc) but being a Newbie, and not knowing, I had to do trial & error......however

part 3. I had to concurrently figure out WHERE in the sketch do I put the Serial.print code.....but being a Newbie, I had to do trial & error on that too. This meant selecting ONE parameter from part 2 and then putting it in ONE spot in the sketch and run it. This is what took all the time.....lots and lots of edited sketches.

part 4. Once I got the Serial.print function to actually print the new message on the Serial Monitor, then I had to figure out how to make it a separate line.

OK for those in the know, I guess this was a 15 second problem....but took me a lot longer.

Bottom line:
See my Final sketch below and
scroll down to where I show //////////////// ADDED ADDED

These two simple lines of code (one was actually added, whereas the second line was an edit) SOLVED my problem.

Wanted to SHARE THIS with the Arduino Community for those that have the same question.

Besides the Sketch, I attached 2 photos.....one showing the response in the Serial Monitor and the other is the actual Scroll box doing it's thing.

//
//   I modified this to have the "new message" show on the SERIAL MONITOR....AFTER pressing SEND
//   I can now see what's scrolling if I'm not looking at the scroll matrix or it's out of view
//   I can now see if I made any typing errors when typing-in the new message
//   See where I show ////////////////  ADDED
//
//
// Use the Parola library to scroll text on the display
//
// Demonstrates the use of the scrolling function to display text received
// from the serial interface
//
// User can enter text on the serial monitor and this will display as a
// scrolling message on the display.
// Speed for the display is controlled by a pot on SPEED_IN analog in.
// Scrolling direction is controlled by a switch on DIRECTION_SET digital in.
// Invert ON/OFF is set by a switch on INVERT_SET digital in.
//
// UISwitch library can be found at https://github.com/MajicDesigns/MD_UISwitch
// MD_MAX72XX library can be found at https://github.com/MajicDesigns/MD_MAX72XX
//

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

// set to 1 if we are implementing the user interface pot, switch, etc
#define USE_UI_CONTROL 0

#if USE_UI_CONTROL
#include <MD_UISwitch.h>
#endif

// Turn on debug statements to the serial output
#define DEBUG 0

#if DEBUG
#define PRINT(s, x) { Serial.print(F(s)); Serial.print(x); }
#define PRINTS(x) Serial.print(F(x))
#define PRINTX(x) Serial.println(x, HEX)
#else
#define PRINT(s, x)
#define PRINTS(x)
#define PRINTX(x)
#endif

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 11
#define CLK_PIN   13  // or SCK    52  13
#define DATA_PIN  11  // or MOSIB  51  11
#define CS_PIN    10  // or SS     53  10

// HARDWARE SPI
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// SOFTWARE SPI
//MD_Parola P = MD_Parola(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

// Scrolling parameters
#if USE_UI_CONTROL
const uint8_t SPEED_IN = A5;
const uint8_t DIRECTION_SET = 8;  // change the effect
const uint8_t INVERT_SET = 9;     // change the invert

const uint8_t SPEED_DEADBAND = 5;
#endif // USE_UI_CONTROL

uint8_t scrollSpeed = 35;    // default frame delay value
textEffect_t scrollEffect = PA_SCROLL_LEFT;
textPosition_t scrollAlign = PA_LEFT;
uint16_t scrollPause = 2000; // in milliseconds

// Global message buffers shared by Serial and Scrolling functions
#define	BUF_SIZE	75
char curMessage[BUF_SIZE] = { "" };
char newMessage[BUF_SIZE] = { "Hello Everyone" };
bool newMessageAvailable = true;

#if USE_UI_CONTROL

MD_UISwitch_Digital uiDirection(DIRECTION_SET);
MD_UISwitch_Digital uiInvert(INVERT_SET);

void doUI(void)
{
  // set the speed if it has changed
  {
    int16_t speed = map(analogRead(SPEED_IN), 0, 1023, 10, 150);

    if ((speed >= ((int16_t)P.getSpeed() + SPEED_DEADBAND)) ||
        (speed <= ((int16_t)P.getSpeed() - SPEED_DEADBAND)))
    {
      P.setSpeed(speed);
      scrollSpeed = speed;
      PRINT("\nChanged speed to ", P.getSpeed());
    }
  }

  if (uiDirection.read() == MD_UISwitch::KEY_PRESS) // SCROLL DIRECTION
  {
    PRINTS("\nChanging scroll direction");
    scrollEffect = (scrollEffect == PA_SCROLL_LEFT ? PA_SCROLL_RIGHT : PA_SCROLL_LEFT);
    P.setTextEffect(scrollEffect, scrollEffect);
    P.displayClear();
    P.displayReset();
  }

  if (uiInvert.read() == MD_UISwitch::KEY_PRESS)  // INVERT MODE
  {
    PRINTS("\nChanging invert mode");
    P.setInvert(!P.getInvert());
  }
}
#endif // USE_UI_CONTROL

void readSerial(void)
{
  static char *cp = newMessage;

  while (Serial.available())
  {
    *cp = (char)Serial.read();
      
         Serial.print(*cp);           /////////////////////////ADDED  ADDED  ADDED this serial print line at left

    if ((*cp == '\n') || (cp - newMessage >= BUF_SIZE - 2)) // end of message character or full buffer
    {
      *cp = '\0'; // end the string
      // restart the index for next filling spree and flag we have a message waiting
      cp = newMessage;
      newMessageAvailable = true;

    }
    else  // move char pointer to next position
      cp++;
  }
}

void setup()
{
  
  Serial.begin(57600);
  
  ////////////////////////////////  ADDED   ADDED  an Edit to the line BELOW  
  ////////////////////////////////  \n  was put after the words  ....scrolling display"
  
  Serial.print("\n[Parola Scrolling Display]\n MY REMINDER with Serial Monitor settings choose Newline and correct baud rate\nType a message for the scrolling display\n ");

#if USE_UI_CONTROL
  uiDirection.begin();
  uiInvert.begin();
  pinMode(SPEED_IN, INPUT);

  doUI();
#endif // USE_UI_CONTROL

  P.begin();
  P.displayText(curMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
}

void loop()
{

#if USE_UI_CONTROL
  doUI();
#endif // USE_UI_CONTROL
            
  if (P.displayAnimate())
  {
    if (newMessageAvailable)
    {
      strcpy(curMessage, newMessage);
      newMessageAvailable = false;
    }
    P.displayReset();
  }
  readSerial();

}