Ok, Thanks to DrAzzy for your help on this. Everything is working fine now and here is the final code that made it all possible. I removed the interrupt enable/disable calls all together and just went with a while loop to give me a 1 sec sample. Of course this means that the interrupt is going to be firing about 8000 times a sec (approx speed of the fan) but it shouldn't be a problem (unless someone does see a problem with that).
const int ledGrn = 0;
const int pwmPin = 1;
const int potPin = A2;
int inVal = 0;
volatile unsigned long NbTopsFan;
int Calc;
int hallsensor = 2;
unsigned long interval = 5000;
unsigned long curTime;
volatile bool cooling = true;
void setup() {
pinMode(ledGrn, OUTPUT);
pinMode(pwmPin, OUTPUT);
analogWrite(pwmPin, 0);
pinMode(potPin, INPUT);
pinMode(hallsensor, INPUT);
attachInterrupt(0, rpm, RISING);
digitalWrite(ledGrn, HIGH);
delay(10);
}
void loop() {
if (cooling) {
inVal = analogRead(potPin);
analogWrite(pwmPin, inVal / 4);
if (millis() >= interval) {
interval = (millis() + 6000UL);
checkFan();
}
} else {
analogWrite(pwmPin, 0);
digitalWrite(ledGrn, LOW);
delay(500);
digitalWrite(ledGrn, HIGH);
delay(150);
digitalWrite(ledGrn, LOW);
delay(150);
digitalWrite(ledGrn, HIGH);
delay(150);
digitalWrite(ledGrn, LOW);
checkFan();
}
}
void rpm() {
NbTopsFan++;
}
void checkFan() {
NbTopsFan = 0;
unsigned long rpmNum = 0;
unsigned long pause = millis() + 1000UL;
while (millis() <= pause) {
rpmNum = NbTopsFan;
}
Calc = ((rpmNum * 60) / 2);
if (Calc >= 6500) {
cooling = true;
digitalWrite(ledGrn, HIGH);
} else {
cooling = false;
digitalWrite(ledGrn, LOW);
}
}