Learning to talk to the display

Figuring out how to talk to the display, and get the MPH to actually display where I want it to. This is try number three or four, and it’s starting to look good. I couldn’t push the button quite fast enough this time to get a two digit MPH, but I did figure out how to get the tens place digit off the screen without blanking everything else when the MPH falls back below 10.

That bit of code looks like so:

  if (mph<=10){
      lcd.setCursor(11, 1); // if the MPH is less than 10, we need to blank the tens column
      lcd.rightToLeft();
      lcd.print(mph);
      lcd.print(" ");
    
  }else{                      // if MPH is 10 or more, just print it. This is good up to 99MPH
      lcd.setCursor(11, 1);   // so don't speed.
      lcd.rightToLeft();
      lcd.print(mph);
  }

Hmmm. More than one way to skin a cat. I just realized I could streamline that like so:

 lcd.setCursor(11, 1); 
 lcd.rightToLeft();
 lcd.print(mph);
 
 if (mph<=10){
      lcd.print(" ");  // if the MPH is less than 10, we need to blank the tens column
 }