Hi all,
I am making an if loop to delete the previous numbers, for example, if the number is 10 and changes to 9, otherwise the display shows 19. So if the number is less than 10 i print "space" and 9, in order to replace the previous 1 with a space and display 9.
if (Frequency<=9.99)
{
lcd.setCursor(0,0);
lcd.print(" ");
lcd.print(Frequency);
}/*
Now I believe the code is quite straight forward, but the arduino as a will of its own and rounds up 9.99 to 10, printing 10 on the display, rendering the loop useless.
Any workarround for this? Sure I could change 9.99 to 9.49 but I would lose all the values in between
// to right justify
lcd.setCursor(0,0);
if (Frequency<10000)
{ lcd.print(" ");}
if (Frequency<1000)
{ lcd.print(" ");}
if (Frequency<100)
{ lcd.print(" ");}
if (Frequency<10)
{ lcd.print(" ");}
lcd.print(Frequency);
Is this what you want to do?
or actual rounding of Frequency?
not sure, but wouldn't this right justify the Frequency to the same spot, whether it is a negative or positive number? I haven't tested, just a thought.
Initial if condition should be "Output_freq > 10?
Unless of course you know it will be 9 or 10 exactly
Have a look at the first question.
The arduino is rounding up the number output to the LCD. So if the result is 9.7 it prints 10 on the LCD. Hence the loop needs to make sure that whatever he rounding the numbers will be absolute.
The above is not a solution, its a workaround. For me its enough, but I would certainly like to know why it rounds the output. The same happens on a graphical TFT (Had the same issue before).