#include <LiquidCrystal.h> //include lcd library
#define MAX_MESSAGE_LENGTH 64 //define max message length
LiquidCrystal lcd(12, 11, 10, 9, 8, 7); //initialize lcd
String messageString; //define output String
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
pinMode(2, INPUT_PULLUP);
lcd.setCursor(0,0);
digitalWrite(13, HIGH);
}
void loop() {
if(Serial.available()){ //if there is something in the serial buffer
messageString = Serial.readStringUntil('\n');
int hexValue = strtol(messageString.c_str(), NULL, 16);
char character = (char)hexValue;
Serial.print(character);
lcd.print(character); //print the message
messageString = "";
delay(100);
}
if(digitalRead(2) == LOW){
lcd.clear();
}
}