Using Bluetooth to send a text message to a scrolling display

I am using the terminal app on phone paired with Bluetooth module tied into Arduino. Now when I send one character at a time from phone (get character then hit the send icon on phone) the Arduino understands the characters sent and displays message correctly. But when I send the message as a whole from phone ( type in the message on the text line and then hit the send icon) the Arduino displays junk.

void getMess()  // get new message to display
       { 
         i = 0;
         selct(2);
         while(newMess == true)
           {
             if(bluetooth.available())   
               {
                 ch = bluetooth.read();
                 bluetooth.print(ch);
                    switch(ch)
                      {
                        case  '.'   :
                                      Mess[i] = '\0';
                                      i = 0;
                                      newMess = false;
                                      break; 
                        case ' '   :
                                      Mess[i] = ch;
                                      i++;
                                      break;
                       /* case  BS   :
                                      ndx--;
                                      break;   */
                        case  '\n'  :
                                      break;
                          default  :
                                      Mess[i] = ch;
                                      i++;  
                                      break;
                      }                 
                 
                  if (i >= NUMCHARS) 
                      i = NUMCHARS - 1;
                
              }
           }
       }

Any ideas on why this works one way and not the other?

BTW when the arduino sends the 'menu' no problems there.

quick look..
looks like your switch is wrong..
you're ending on a dot, should be the newline \n..

really, could take the switch out and replace with if..
want all chars up to the \n..

unless of course you want to omit and exchange certain chars..

     if (i >= NUMCHARS) {
              i = NUMCHARS - 1;
            //get out of while..
             newMess = false;
            }

untested, sorry..

void getMess()  // get new message to display
{
  i = 0;
  selct(2);
  while (newMess == true)
  {
    if (bluetooth.available())
    {
      ch = bluetooth.read();
      bluetooth.print(ch);
      if (ch == '\n')
      {
        Mess[i] = '\0';
        newMess = false;
      } else {
        Mess[i] = ch;
        i++;
      }
      if (i >= NUMCHARS) {
        i = NUMCHARS - 1;
        newMess = false;
      }

    }
  }
}

more info........

in the terminal app for phone under settings subset send I increase time between characters to 150ms. This allows the send text line to send the entire message line correctly. The Blue tooth module is set to 9600. I have changed the code to look for the '\n' character to find end of message and set the send delimiter to LF in the Terminal app on phone.

Now this is VERY important !
DO NOT use the app Serial Terminal for phone. It requires access to all files on phone and tracking info else it won't run. Very suspicious to me......................

the Arduino sends to phone a request to run "Diags" and waits for y/n response. This allows the testing of all RGB leds on message board one at a time. Then requests message to display. After this it scrolls message using defaults and checks for cmdmode from phone.
If the Arduino gets a cmdmode request then a "menu" shows up on phone and from there you are able to select options. So far you can change scroll speed, text color, reset time, new message and exit.
when phone sends exit cmd then the returns to scrolling message.

Sounds like you're making great progress, awesome job..
and yes, ditto lot's of apps can be not so nice, so listen to your gut, it's probably right.. :slight_smile:

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