How to catch the Enter key received by Bluetooth? I got some code to receive characters from Bluetooth and code and print it back to the LCD display.

However, want to detect the Enter character to be the input signal, in other words, not to print nothing to the display until Enter is pressed.

An strange character is shown at display for Enter but I can't catch it.

This is my code:

#include &lt;Wire.h&gt; 
#include &lt;LiquidCrystal_I2C.h&gt;

LiquidCrystal_I2C lcd(0x20,16,2); 

void setup()
{
  lcd.init();
  lcd.backlight();
  pinMode(13,OUTPUT);
  Serial.begin(9600);
  Serial1.begin(9600);

}

void loop()
{

  while (Serial1.available())
  { 
    char dato= Serial1.read(); //Comprobamos el dato 

     lcd.print(dato);


    switch(dato) { 
    case '#':  
      Serial.println("GATO...");
    break;  
    case 'e':  digitalWrite(13,LOW); 

    Serial1.println("Led apagado");
    break;  
      case 'r':  
      digitalWrite(13,HIGH); delay(200); 
      digitalWrite(13,LOW); delay(200);

      Serial1.println("Led intermitente");
      break;
  } //fin switch

}//serial disponible


}//fin programa
It depends on what the enter key sends. It may be just CR (carriage return), LF (line feed), or both. You can check the ASCII table for the hex values for those characters.

LF is 0x0A and CR is 0x0D. Those are the characters you're looking for, you can add a if for these cases in order to guard the call to lcd.print(dato):

char dato= Serial1.read(); //Comprobamos el dato 
if (dato != 0x0A &amp;&amp; dato != 0x0F)
    lcd.print(dato);