From my last post (Arduino-oled-display) I added a new function that allows me to send notification/messages from my terminal (linux) to my Arduino and it shows it through the little Oled screen. Here I will share the commands and code lines to get done the serial communication on your project.
void loop() {
while (Serial.available() > 0)
{
char recieved = Serial.read();
inData += recieved;
// Process message when new line character is received
if (recieved == '\n')
{
Serial.print("Arduino Received: ");
Serial.print(inData);
//digitalWrite(ledPin, HIGH);
//
if(inData == "HELLO\n")
{ // DON'T forget to add "\n" at the end of the string.
Serial.println("HELLO");
//digitalWrite(ledPin, LOW);
display.clearDisplay();
display.setCursor(0,0);
display.setTextSize(2);
display.print("Hi jose!");
display.display();
delay(3000);
}
inData = ""; // Clear received buffer
}
}
}