LCD Alternating Mesages

Hi all,

A little assistance is required please....

I am running a Uno with a 2x20 LCD displaying serial data.
The sketch running is:-

The circuit:

  • LCD RS pin to digital pin 12
  • LCD Enable pin to digital pin 11
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2
  • LCD R/W pin to ground
  • 10K resistor:
  • ends to +5V and ground
  • wiper to LCD VO pin (pin 3)

*/

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int backLight = 13; // pin 13 will control the backlight

void setup()
{
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.

lcd.begin(20,2);
lcd.clear(); // start with a blank screen
lcd.setCursor(3,0); // set cursor to column 0, row 0 (the first row)
lcd.print("Waiting"); // change this text to whatever you like. keep it clean.
lcd.setCursor(3,1); // set cursor to column 0, row 1
lcd.print("System Active");
delay(1000);
// initialize the serial communications:
Serial.begin(9600);
}

void loop()
{
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(1000);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(Serial.read());
}
}
}

Now, all works well and displays any messages that arrive but I would like the display to alternate between any other messages that might arrive.

Can anyone assist.

Many thanks.....

First things first:

(1) Go back and edit your original post and use 'code' tags so the code is legible as such.

(2) Edit the comments so that they explain why the steps are being done, not what they are doing. Also make sure that the comment accurately reflects the code.

(3) Explain specifically what you mean by "I would like the display to alternate between any other messages that might arrive."

Right now your code is displaying information as it arrives. Each incoming character is displayed and then is lost. If you want to redisplay it later you will first have to store it somewhere.

Don