BLYNK
BLYNK.IO       📲 GETTING STARTED       đź“— DOCS       👉 SKETCH BUILDER

Cant display input in terminal to led matrix 32x8

I am currently working in led matrix 32x8 and using blynk as controller. I have a problem in displaying text in my matrix led from the input in the terminal of blynk. Everytime I type and send a message from terminal, it only appears in serial monitor and didn’t display in led martix. The matrix only change the display if I only type in the serial monitor and not in terminal.

CODE:

   #define BLYNK_PRINT Serial
   #include <MD_Parola.h>
   #include <MD_MAX72xx.h>
   #include <SPI.h>

   #include <ESP8266WiFi.h>
   #include <BlynkSimpleEsp8266.h>

   #define BLYNK_TEMPLATE_ID "TMPLgmba-Rsg"
   #define BLYNK_DEVICE_NAME "LED"
   #define BLYNK_AUTH_TOKEN "BSG02j76Sp55Wa47tg68AnJ2DeMb8zFX" //Enter your blynk auth token

   char auth[] = BLYNK_AUTH_TOKEN;
   char ssid[] = "HUAWEI-C38E";//Enter your WIFI name
   char pass[] = "72261758";//Enter your WIFI password

   // 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 4
   #define CLK_PIN   D13
   #define DATA_PIN  D11
   #define CS_PIN    D10

   WidgetTerminal terminal(V3);

   BLYNK_WRITE(V3){
     String textIn = param.asStr();
     Serial.print(textIn + "\n");
   }

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

   uint8_t scrollSpeed = 25;    // 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! Enter new message?" };
   bool newMessageAvailable = true;


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

     while (Serial.available())
     {
       *cp = (char)Blynk.virtualWrite(V3, textIn);
       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(9600);
     Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
     P.begin();
     P.displayText(curMessage, scrollAlign, scrollSpeed, scrollPause, scrollEffect, scrollEffect);
   }

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

    ```
I HOPE SOMEONE CAN HELP ME! THANK YOU!

@Lester_Aguila please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

first of all, you should read this
https://docs.blynk.io/en/legacy-platform/legacy-articles/keep-your-void-loop-clean

You’ve edited your post, but despite me providing you with triple backticks to copy/paste you’ve decided to use different characters instead.

Please edit your post and use the correct characters, otherwise your unformatted code will be deleted.

Pete.

That’s because every time you send a message from the terminal widget attached to pin V3 it triggers the BLYNK_WRITE(V3) callback function, and as you can see, …

all that function does is to print the text to the serial monitor.

A few other comments…

These lines of code should be at te very top of your sketch…

if you do that then specifying the server name and port in your Blynk.begin command isn’t necessary…

It’s also recommended that you don’t try to do things like reading your serial port in the void loop. Blynk doesn’t like this.
You’d probably be better just using Blynk for the text input. It will also make your code structure much neater.

Pete.

Thank you sir Pete, I already solve the problem. I convert the string into char and copy it to the another char who are use in displaying the text in led.

this is the part I changed.

String str;
char cstr[75];
unsigned int mlength; // message length 
int textspeed = 100; // default speed
String myMessage;

BLYNK_WRITE(V3){
  myMessage = param.asStr();
  mlength = myMessage.length(); // find the number of characters in a message.
  str = myMessage;
  str.toCharArray(cstr,75);
  beep();
  strcpy(curMessage, cstr);
  newMessageAvailable = false;
}


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++;
  }
}