Reading a value on lcd with bluetooth module

Hello there !

I am currently working on a system that needs to recieve a variable from our smartphone app created on App Inventor, to the Arduino card. I’m currently able to get the value of it and print it on the serial monitor, but I’m having a little problem : if I send for example a value of 38, the LCD is displaying this : “16 51 56”.

I don’t really know what I have to change to make it working, so I’m asking to you some help !

Here is my Arduino code :

#include <Wire.h>
#include <rgb_lcd.h>
#include <SoftwareSerial.h>

#define MASTER 0

int test = 62;
const int RGB_Red = 81;
const int RGB_Green = 168;
const int RGB_Blue = 255;

SoftwareSerial BTserial(6, 7); // RX | TX
rgb_lcd lcd;

int valeur_var;
String mot;
 
void setup() 
{
    lcd.begin(16, 2);
    lcd.setRGB(RGB_Red, RGB_Green, RGB_Blue);
    lcd.setCursor(0, 0);
    lcd.print("Ready...");
    delay(2000);
    lcd.clear();
    Serial.begin(9600);
    Serial.println("Arduino is ready");
    BTserial.begin(9600);
    BTserial.flush();
    BTserial.write("Ready\n");  
}
 
void loop() {
  #if MASTER
    BTserial.write(45);
    int bytesSent = BTserial.print(test);
    delay(800);
    
  #else
    if (BTserial.available())
    {  
        valeur_var = BTserial.read();
        Serial.write(valeur_var);
        lcd.setCursor(0, 0);
        lcd.print(valeur_var);
        delay(400);
    }
 
    if (Serial.available())
    {
        valeur_var =  Serial.read();
        BTserial.write(valeur_var);  
    }
  
  #endif
}

If you have any idea, or example of code that could help me, pls share it to me :slight_smile:

Thanks for taking a look to my topic !
Have a nice day :slight_smile:

16 51 56

Ascii code 16 = DLE (a control character) Ascii code 51 = '3' Ascii code 56 = '8'

You need to check to make sure that what you send is how you are receiving the character(s). If you are sending a readable ascii string then read it as a readable ascii characters or convert then before you print them on the LCD (ie, keep it consistent). The DLE may be a start character that you will have to filter out.

Hard to give more advice without seeing the sending end.

Thank you for your reply, i'll check what I can do :)

The problem is that I dont know how I can ignore the first transmission, I'm currently looking on Internet but not finding so much.