if (rpm != lastRPM) // only print to LCD if rpm changed
// ******** this is after autoformat. Notice how only the one line is indented? ***********
lcd.setCursor(6, 0);
lcd.print(" "); // overwrite old data
lcd.setCursor(8, 0); // reset cursor
lcd.print(rpm);
lcd.setCursor(6, 1);
lcd.print(" "); // overwrite old data
lcd.setCursor(8, 1); // reset cursor
lcd.print(ips, 1);
You left out the curly brackets that enclose the body of the if structure. Without the curly brackets the only line that will execute conditionally is the line right after the if. So only the setCursor executes conditionally. The rest will execute every time.
Here it is with the curly brackets:
if (rpm != lastRPM) // only print to LCD if rpm changed
{
lcd.setCursor(6, 0);
lcd.print(" "); // overwrite old data
lcd.setCursor(8, 0); // reset cursor
lcd.print(rpm);
lcd.setCursor(6, 1);
lcd.print(" "); // overwrite old data
lcd.setCursor(8, 1); // reset cursor
lcd.print(ips, 1);
lastRPM = rpm;
}
Edit: fixed the absence of the setting of lastRPM.
A good habit to get into is to use the IDE autoformat tool (ctrl-t or Tools, Auto format) frequently to indent the code in a standard way. That will often point out mistakes like missing or misplaced curly brackets and parenthesis.