Help with Device Failure alarm coding

Quick background so you know what I'm doing:

  • I've created a tachometer output to an LCD screen to monitor the Hall sensor Output from a waterpump and do the calculation to convert the count to RPM.

  • I've added a failure alarm, well not really, more like a low rpm warning display.(which is my issue)

The best I've figured out at the moment is to add a couple lines stating that if RPM drops below a certain threshold, clear the screen, blink every half a second and display "Pump Failure!!!"

This work fine, except for the fact that if I outright unplug the pump from it's power, thus removing the signal to the #2 digital pin...the output just stop at whatever it was previously at and no alarm goes off.

For example, testing with a PC fan with the same RPM output wire...If i slow the fan down past 800rpm with my finger it works fine and the alarm triggers. HOWEVER, if I blatently kill power to the fan, or stop the fan blades completely and abruptly. Nothing happens. The lcd just sticks at whatever RPM it was just at before I killed power to the fan or stopped teh blades.

Is there a function that i can call that will throw this same type of alarm, but will throw it when it senses that pin2 is no longer receiving a signal?

Im VERY new to coding and havent done it in 6+ years, so bear with my lack of proper use of terminology:

Below is my coding:

// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

volatile byte rpmcount;
unsigned int rpm;

unsigned int rpmrate;

unsigned long timeold;

void setup()
{
Serial.begin(9600);
lcd.begin(16, 2); // intialise the LCD
digitalWrite(2,HIGH);
attachInterrupt(0, rpm_fun, RISING);

rpmcount = 0;
rpm = 0;
timeold = 0;
}

void loop()
{
if (rpmcount >= 20) {
//Update RPM every 20 counts, increase this for better RPM resolution,
//decrease for faster update
rpm = 30*1000/(millis() - timeold)*rpmcount;
timeold = millis();
rpmcount = 0;

Serial.println(rpm,DEC);

lcd.clear();
lcd.setCursor(4,0);
lcd.print(rpm);
lcd.setCursor(9,0);
lcd.print("RPM");
}

if (rpm <= 800)
{
lcd.clear();
lcd.setCursor(1,1);
lcd.print("PUMP FAILURE!!!");
delay(500);
lcd.noDisplay();
delay(500);
lcd.display();
}
}

void rpm_fun()
{
rpmcount++;
//Each rotation, this interrupt function is run twice
}

void rpm_fun()
{
rpmcount++;
//Each rotation, this interrupt function is run twice
}

Then rpmcount is a lousy name, isn't it? The variable does not count the number of rotations or the number of rotations per minute. We ask people to give variables meaningful names because it helps YOU know what the program is doing.

If the thing that triggers the ISR is a pulse from a hall effect sensor, then what you are counting is pulses, which is what the variable should be called.

The thing to use to trigger the calculation of rpm is NOT the number of pulses. It is the time since the last update was done. Since the pulse count quits changing, so does the rpm value, as you compute it.

The other part of the equation, time, does continue to change, so that is what you should use as the basis for when to change the displayed value.