Counter Problem using an LCD display

I'm currently using a few conditions to set whether a counter will count up or down. The counting works perfectly all round except for one part - when counting down from 10 to 9, or even 100 to 99, the LCD displays '90' or '990' rather than 9 or 99. Any ideas what to do?

Fix the code so that it doesn't only write the new number, but also fills any extra positions (e.g. where the 0 from the previous number was) with as whitespace.

place this code inside your void loop()

  #define length 16.0
  unsigned char b;
  for (int i =0;i<(length-b);i++)
  {
    lcd.print(" ");
  }

Fixed it for me, may be messy but it works :slight_smile:

That has worked perfectly! Many thanks janvier123 :smiley:

Np,

Ive been searching for a few hours before i found some code :)

So I've been using this code for a good couple of weeks on numerous programs and it has worked fine, except the latest... on the LCD display I have a counter, an RPM reading and another reading, and everything works fine except when the counter counts down, it displays "90" then "80", "70" etc until it gets to 0, where it prints "00". Everything else on the display works fine except this!

Any ideas on what it could be or how to go about fixing it?

Once you write a character to the LCD it stays there until it is overwritten. To 'erase' a character you have to overwrite it with a 'space'.

Here is a thread with several solutions: -->http://arduino.cc/forum/index.php?topic=94633.0

Don