I need a program where the lcd display would show words and a specific word needs to blink.
For example, I have this:
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup() {
lcd.begin(16, 2);
lcd.print("It will blink");
}
void loop() {
lcd.noDisplay();
delay(500);
lcd.display();
delay(500);
}
Is there any way to make only the word "blink" blink?
Not like you're thinking, as far as I know.
Only:-
void loop()
{
lcd.print("It will blink");
delay(500);
lcd.clear();
lcd.print("It will ");
delay(500);
}
or
void setup()
{
lcd.print("It will blink");
}
void loop()
{
lcd.setCursor(8,0);
lcd.print(" ");
delay(500);
lcd.setCursor(8,0);
lcd.print("blink");
delay(500);
}
Overwrite the word with blanks, and rewrite it at periodic intervals.
or make your own function and pass the strings to blink...
something like this untested version:
#include <Wire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
void setup()
{
lcd.begin(16,2);
}
void loop()
{
flashDisplay(" Hello, ARDUINO ", " It will blink ");
}
void flashDisplay(const char* firstLine, const char* secondLine)
{
static unsigned long lastTime = 0;
static bool flashOn = false;
if(millis() - lastTime > 500UL)
{
if(flashOn)
{
lcd.setCursor ( 0, 0 );
lcd.print(firstLine);
lcd.setCursor ( 0, 1 );
lcd.print (secondLine);
}
else
{
lcd.clear();
}
flashOn = !flashOn;
lastTime = millis();
}
}