I am building a weather station, I have everything working except the wind speed. If 0-9 no problem, but when the 10's digit comes into play, the next time with the single digit speed, it still shows the 10's digit, how do I repair this?
You should always print 2 characters. Add a space or a '0' if the value is less than 10. Example:
int value;
...
lcd.setcursor(10, 1);
if (value < 10) lcd.print("0");
lcd.print(value);
or this way:
int value;
...
lcd.setcursor(10, 1);
if (value < 10) lcd.print(" "); // Print space before units
lcd.print(value);
That is not the answer, this is measuring wind speed that could be up 20 or as low as 4. So once the speed gets over 10 or more it leaves that digit behind.
Dave
| ruilviana
September 29 |
- | - |
docdoc:
int value; ... lcd.setcursor(10, 1); if (value < 10) lcd.print("0"); lcd.print(value);
or this way:
int value;
...
lcd.setcursor(10, 1);
if (value < 10) lcd.print(" "); // Print space before units
lcd.print(value);
Could you post some pictures of what you mean... the solutions above look fine, but possibly we are not understanding exactly what you mean.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.