LCD character flashing

hi, I was wondering on how I could make the " !$ $! " flash in this code.

I've tried a few things but it keeps messing up the upper line for some reason (line 0)

I want the first line to read " take a card" while the bottom line changes

I'm using a 2x16 LCD

I'm a musician and I mounted this little project to my tip jar.

/*
  LiquidCrystal Library - Hello World

 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

  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
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)

 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe

 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

// 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);


  const int echo = (7); //  ultra sonic sensor
  const int trig = (8); //  ultra sonic sensor
  int lowBattLed = (9); //  red led indicate low batt 
  int lowBattSen = (A3); //  sense batt voltage off voltage divider 2:1 
  int sensorValue = 500;
  int extraA = (6); // not used
  int extraB = (10); // not used
  int extraC = (13); // not used
  long duration, cm;

void setup() {

  pinMode(lowBattLed,OUTPUT);
  pinMode(trig,OUTPUT);
  pinMode(echo,INPUT);

// show LED works and program has started
  digitalWrite(lowBattLed,HIGH);
  delay(1000);
  digitalWrite(lowBattLed,LOW);
  delay(750);
  digitalWrite(lowBattLed,HIGH);
  delay(1000);
  digitalWrite(lowBattLed,LOW);
  delay(750);
  digitalWrite(lowBattLed,HIGH);
  delay(1000);
  digitalWrite(lowBattLed,LOW);
  
 
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("   TAKE A CARD  ");
  }

void loop() {

     
  digitalWrite(trig,LOW);      // activate Ping sensor 
  delayMicroseconds(5);
  digitalWrite(trig,HIGH);
  delayMicroseconds(10);
  digitalWrite(trig,LOW);
  
  duration = pulseIn(echo,HIGH); //read trig

  sensorValue = analogRead(lowBattSen); // low battery 

  cm = (duration / 2) / 29.1; // distance calculation
  

lcd.setCursor(0, 1);

if (sensorValue < 500)  // indicate low Battery
  {
    digitalWrite(lowBattLed,HIGH);
    delay(500);
    digitalWrite(lowBattLed,LOW);
    delay(700);
    digitalWrite(lowBattLed,HIGH);
    delay(500);
    digitalWrite(lowBattLed,LOW);
    delay(2000);
    digitalWrite(lowBattLed,HIGH);
    delay(500);
    digitalWrite(lowBattLed,LOW);
    delay(700);
    digitalWrite(lowBattLed,HIGH);
    delay(500);
    digitalWrite(lowBattLed,LOW);
    delay(2000);
  }

if
     ( cm <= 17.5 )
   {
   lcd.print("!$ THANK YOU  $!"); 
   digitalWrite(lowBattLed,HIGH):
   delay(2000);
   digitalWrite(lowBattLed,LOW);
   }

else
{
  lcd.print("Like On FaceBook");
}}

my goal is to alternate between "!$ THANK YOU $!" and " THANK YOU " in the bottom line of the LCD

So making the !$ appear and disappear is easy, just print spaces over them. Or blank the whole screen and print !$THANK YOU $! and then clear the screen and print THANK YOU. That part is easy.

if ( cm <= 17.5 )
   {
   lcd.print("!$ THANK YOU  $!"); 
   digitalWrite(lowBattLed,HIGH):
   delay(2000);
   digitalWrite(lowBattLed,LOW);
   }

Just write more lines with less delay in between printing the two things back to back. print 1 delay print the other delay print the one delay etc.

Better would be to ditch the delay altogether and embrace a state machine style of coding for this. But that's more than I'm prepared to discuss in a forum post. "State Machine Coding" is something you can google and get a lot more on.

PS. PLEASE format your code before you post it. Hit Control-T in the IDE and it will do it for you. Please don't post code with if statements with conditions not on the same line and random spaces and braces wandering all over the place. You want us to help, so it is a good idea not to try to make the code hard to read. When it is too hard to read then people just skip on to the next thread and you don't end up getting any responses.

I've tried that but it never worked right.

I tried

lcd.print("!$ THANK YOU $!");
delay(500);
lcd.print("   THANK YOU   ");
delay(500);
lcd.print("!$ THANK YOU $!");
delay(500);
lcd.print("   THANK YOU   ");
delay(500);
lcd.print("!$ THANK YOU $!");
delay(500);
lcd.print("   THANK YOU   ");
delay(500);

lcd.print with symbols then w/o symbols so it would alternate but every time the IF statement was true for that function it would write " you !$ thank" on the top line too. it wasn't holding the top line as
"TAKE A CARD"

With an LCD, it's not enough just to write a print statement. If you want it to print in a certain place then you have to put the cursor there.

You can skip the erase if you write over the line with the same number of characters each time.
But, in both cases you have to position the cursor to the position you wish to write to.

  lcd.setCursor(0,1);
  lcd.print("!$ THANK YOU $!");
  delay(500);
  lcd.setCursor(0,1);
  lcd.print("    THANK YOU    "); 
  delay(500);

I've even tried that too. I added a set.cursor(0, 1); before every lcd.print and it still was giving me an issue

What was the issue? Can you post that code with its output?

void loop() {

     
  digitalWrite(trig,LOW);      // activate Ping sensor 
  delayMicroseconds(5);
  digitalWrite(trig,HIGH);
  delayMicroseconds(10);
  digitalWrite(trig,LOW);
  
  duration = pulseIn(echo,HIGH); //read trig

  sensorValue = analogRead(lowBattSen); // low battery 

  cm = (duration / 2) / 29.1; // distance calculation
  

lcd.setCursor(0, 1);

if (sensorValue < 500)  // indicate low Battery
  {
    digitalWrite(lowBattLed,HIGH);
    delay(500);
    digitalWrite(lowBattLed,LOW);
    delay(700);
    digitalWrite(lowBattLed,HIGH);
    delay(500);
    digitalWrite(lowBattLed,LOW);
    delay(2000);
    digitalWrite(lowBattLed,HIGH);
    delay(500);
    digitalWrite(lowBattLed,LOW);
    delay(700);
    digitalWrite(lowBattLed,HIGH);
    delay(500);
    digitalWrite(lowBattLed,LOW);
    delay(2000);
  }

if
     ( cm <= 17.5 )
   {
   digitalWrite(lowBattLed,HIGH);
   lcd.setCursor(0,1);
   lcd.print("!$ THANK YOU  $!"); 
   delay(500);
   lcd.setCursor(0,1);
   lcd.print("   THANK YOU    ");
   delay(500);
      digitalWrite(lowBattLed,HIGH);
   lcd.setCursor(0,1);
   lcd.print("!$ THANK YOU  $!"); 
   delay(500);
   lcd.setCursor(0,1);
   lcd.print("   THANK YOU    ");
   delay(500);
      digitalWrite(lowBattLed,HIGH);
   lcd.setCursor(0,1);
   lcd.print("!$ THANK YOU  $!"); 
   delay(500);
   lcd.setCursor(0,1);
   lcd.print("   THANK YOU    ");
   delay(500);
      digitalWrite(lowBattLed,HIGH);
   lcd.setCursor(0,1);
   lcd.print("!$ THANK YOU  $!"); 
   delay(1000);

   digitalWrite(lowBattLed,LOW);
   }

else
{
  lcd.print("Like On FaceBook");
}}

ok I tried this the first time and it didn't work.... now it is.

I've had issues with this project concerning the VR too. (not saying they're tied together) but I'm not sure wtf is going on.... definitely no more cheap boards for me though.

VR???

Voltage Regulator. I don't see how one would effect the other but it was acting strange on batt power then the VR went bad and it only works on 5v VCC from the FTDI

the pro mini is from Gikfun.

You keep using terms like, "working fine" or "acting strange" or "wouldn't work". Do you understand how useless those are? You can't troubleshoot something if the only symptom you have is "acting funny". What does funny mean? Did it make you laugh? Be detailed in how you communicate those things. "The voltage dropped to 2.3V everytime I flipped switch S2", now that is a real symptom that someone can tell something from.

yes I did giggle a little bit.....

and my apologies, I will try to be more accurate. I did give and example of what it was doing it prior posts. but since it wasn't really an issue that I could give you Voltage readings or if there were output or not, not even an error code then its semi-difficult to explain what is going on. next time I will take pics.

I try to get things figured out at least half way before I post a question.

LandonW:
yes I did giggle a little bit.....

and my apologies, I will try to be more accurate. I did give and example of what it was doing it prior posts. but since it wasn't really an issue that I could give you Voltage readings or if there were output or not, not even an error code then its semi-difficult to explain what is going on. next time I will take pics.

I try to get things figured out at least half way before I post a question.

I was speaking more to the thing with the regulator. You just said it was "acting strange". Even if you don't have a voltage reading, there was something that was happening that you called strange. What was that? That's what I mean. Don't just say it is "strange", tell me how it is "strange".

the strange was...

my first program that I wrote with the "!$" symbols flashing didn't work right. I used the same code as posted above but the top line of the LCD would change too.

I rewrote the code to not flash the symbols.

the next day it didn't work on Batt power anymore (again, not saying the software and hardware are connected)

I have an external VR on order

from a whim I started playing with the code again for shiz and giggles but the only way I could test it was from the FTDI module to power it.

when I tested it off of that it started working like it should.

I guess I should've tried the same code again before I posted but I didn't think the software and hardware were connected so I assumed i'd have the same problem.

that's the reason for the post.

thank you for your help by the way

LandonW:
my first program that I wrote with the "!$" symbols flashing didn't work right. I used the same code as posted above but the top line of the LCD would change too.

If it didn't work the same and printed in a different place, then despite what you might think it wasn't exactly the same code.