LCD: getting zeros on the right of values displayed

Hello.

When I display a value (for eg. 0 to 255) and it goes below 99, the right algorism is still showing up, meaning that the number displayed is 990. this renders the reading useless. and if it goes below 9, the reading I get is 900.

I've tried using lcd.rightToLeft() but it just makes the number to be written in reverse.

what can I do to solve this?

bytheway, the numbers on my LCD screen are flickering. what is the reason? they are the readings from trimpots maped to usable ranges.

thanks in advance, and sorry for the bad english.

You need to look at the size of the number and add two spaces if it is less than 10 or one space if it is less than 100 but greater than 10. Use an if statement to se how many spaces to add after displaying the number.

the numbers on my LCD screen are flickering. what is the reason?

You are probbly up dating it too often, only update when the number changes.

When I display a value (for eg. 0 to 255) and it goes below 99, the right algorism is still showing up, meaning that the number displayed is 990. this renders the reading useless.

This problem, and at least two solutions have been discussed several times in the past. Here's one: http://arduino.cc/forum/index.php?topic=94633.0.

bytheway, the numbers on my LCD screen are flickering. what is the reason? they are the readings from trimpots maped to usable ranges.

My crystal ball is not functioning so I cannot read your code today. My guess would normally be that your loop includes an lcd.clear() instruction but if it did then you wouldn't have your other problem.

Don

thanks for pointing out the issue in my code. I simply added some IF statements and got it working nicely.

  lcd.setCursor(8, 1);
  lcd.print("Fuel");
  lcd.setCursor(12, 1);
  if (fuel < 100){
    lcd.print(" ");
  }
  if (fuel < 10){
    lcd.print(" ");
  }
  lcd.print(fuel);
  lcd.setCursor(15,1);
  lcd.print("l");

there is no lcd.clear() on the loop (only in the setup to show a simple welcome message). now i’m trying to implement a small delay between the readings so the flickering may be dealt with.

again, thanks for the help.

EDIT: out of ideas to reduce the flickering of the data. here goes a segment of the code showing how i’m dealing with the inputs. it is repeated 3 times for different inputs.

  oil = map(analogRead(trim1), 0, 1023, 0, 100);
  temp = map(analogRead(trim2), 0, 1023, 0, 250);
  fuel = map(analogRead(trim3), 0, 1023, 0, 60);

  lcd.setCursor(0, 0);
  lcd.print("Oil");
  lcd.setCursor(4, 0);
  if (oil != lastoil) {
    if (oil < 100){
      lcd.print(" ");
    }
    if (oil < 10){
      lcd.print(" ");
    }
    lcd.print(oil);
    lastoil = oil; 
  }

i tried to make a small routine that if the input does not change i would not need to update the screen. seems that it is useless.

You are still doing this:-

 lcd.setCursor(0, 0);
  lcd.print("Oil");
  lcd.setCursor(4, 0);

every time even when oil == lastoil