I am trying to get the LCD to print 3 decimals if the answer is below 1, but if answer is 1 or greater, then I would like only 1 decimal to be printed. i.e.
if < 1; print .xxx; else if >=1; print y.x
(this ver 0018 float thingy for decimals is really nice, and works!
From the reference for the if, else I find the following example:
if (pinFiveInput < 500)
{
// action A
}
else
{
// action B
}
I think I have the same thing here:
if (amp < 1.0);
{
lcd.setCursor(8,0);
lcd.print("A=");
lcd.print(amp, 3);
}
else
{
amp >= 1.0;
lcd.setCursor(8,0);
lcd.print("A=");
lcd.print(amp, 1);
}
but I get an error msg saying:
In function 'void loop()':
error: 'else' without a previous 'if
What am I missing? Why does the else not see the if statement above? I even tried writing the else as:
else (amp >= 1.0);
{
lcd.setCursor(8,0);
lcd.print("A=");
lcd.print(amp, 1);
}
I have used if, else in the past:
if (amp < .01)
{amp = 0;}
else (amp >= .01);
amp = (amp/.0405);
Is it because I'm using the lcd.print statements as the if, else?
Thank ya'll for any help and suggestions.
Ken H>