Playing with my LCD, what is the code for flashing some written text on the LCD screen?
Something like this maybe ?
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
void setup()
{
lcd.begin(16, 2);
}
void loop()
{
lcd.print("Some text");
delay(500);
lcd.clear();
delay(500);
}
Ahh yeah, righto. I just thought there might be a command line for it already.
Next ?
The text I have displayed now, (just mucking around playing connect 4 with the kids is)
GAME SCORE
Peter Nicholas
0 1
Game On
Want to make the GAME SCORE flash for example.
That line of code you gave me would make the text flash as long as I repeat it.
But I only want the first line, or 2nd line, or line 1 and line 4 to flash only.
How would you do it then?
Can you have mini loop's going ie void loop for line 1 of text? Then normal then void loop for line 4 text?
Peter
Have a look at this for some ideas
#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
void setup()
{
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("line 1");
lcd.setCursor(0,1);
lcd.print("line 2");
}
void loop()
{
for (int count=0; count <= 5; count++)
{
lcd.setCursor(0,0);
lcd.print(" ");
delay(500);
lcd.setCursor(0,0);
lcd.print("line 1");
delay(500);
}
for (int count=0; count <= 5; count++)
{
lcd.setCursor(0,1);
lcd.print(" ");
delay(200);
lcd.setCursor(0,1);
lcd.print("line 2");
delay(200);
}
}
There are better ways to do it but you will get the general idea.
Try this.
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7,8,9,10,11,12);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("GAME SCORE");
}
void loop() {
// Turn off the cursor:
lcd.noDisplay();
delay(250);// change for faster flash
// Turn on the cursor:
lcd.display();
delay(250);// change for faster flash
}
Is there really no function to display a portion of flashing text on LCD?
You can always write your own function. For example:
void FlashMessage(char *msg, int col, int row, int repeat)
{
char temp[] = " "; // Enough spaces to fill one display line
lcd.setCursor(col, row);
lcd.print(msg);
for (int i = 0; i < repeat; i++) {
lcd.setCursor(col, row);
lcd.print(temp);
delay(PAUSE);
lcd.setCursor(col, row);
lcd.print(msg);
delay(PAUSE);
}
}
For example, you could use this:
#define PAUSE 500 // Set at top of source code file
// some code...
FlashMessage("Game Score", 5, 0, 5); // Set the message to column 5, row 0, and flash 5 times.
It would be more useful to also pass in the delay period rather than using the #define.
Thank you very much, it will fit my need.
Thanks. very useful.