Hello,
I am having some difficulties with clearing the lcd and moving on with the sketch. I never used lcd.clear before.
The sketch is the "Hello, world!" and counting example in the Arduino LCD library.
I want the sketch to display the "Hello world!" message and count to 10 and then clear the LCD and display "Hello again!" and start counting again.
I can do the "Hello world!" and count part and if I don't insert the lcd.clear command I get the "Hello again!" message after the 10 seconds printed on the second row after the time counter. On the first row I still get "Hello world!"
If I insert lcd.clear all the characters on the screen are blinking fast. I guess the sketch starts, I get the "Hello world!" message, the LCD is cleared and then I get "Hello world!" message again and the lcd is cleared again.
It loops both the message and the lcd.clear command.
Here is the modified sketch
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
{lcd.print("hello");
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);}
if (millis()/1000 >10)
lcd.clear();
{lcd.print("hello2");
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);}
}
I have moved the first "hello". In the original sketch with the "hello" in the void setup part of the sketch, lcd.clear was clearing the "hello" word but it kept looping the counter and clearing it. I found it interesting that even if it cleared the lcd, the counter would count the seconds correctly.
Any help would be appreciated.