Timer interrupt question

Hello everyone

Okay, I am not an advanced and knowledgeble arduino techie but am willing to improve, I hope you can understand this easy one!
here is my question:
On a tachometer project, I have to use some Timer interrupt feature, since I want to count the Rev per Minute.
Here is an example of what I found on the net. After cleaning some syntax errors, I still don’t understand the timer feature:
here is the bit:

#include <LiquidCrystal.h>
LiquidCrystal lcd(3, 5, 9, 10, 11, 12);

volatile float time = 0;
volatile float time_last = 0;
volatile int rpm_array[5] = {0,0,0,0,0};

void setup()
{
//Digital Pin 2 Set As An Interrupt
attachInterrupt(0, fan_interrupt, FALLING);

// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(“Tours/mn:”);
}

void loop()

{
int rpm = 0;

while(1){

//Slow Down The LCD Display Updates
delay(400);

//Clear The Bottom Row
lcd.setCursor(0, 1);
lcd.print(" ");

//Update The Rpm Count
lcd.setCursor(0, 1);
lcd.print(rpm);
}
////lcd.setCursor(4, 1);
////lcd.print(time);

//Update The RPM
if(time > 0)
{
//5 Sample Moving Average To Smooth Out The Data
rpm_array[0] = rpm_array[1];
rpm_array[1] = rpm_array[2];
rpm_array[2] = rpm_array[3];
rpm_array[3] = rpm_array[4];
rpm_array[4] = 60*(1000000/(time*7));
//Last 5 Average RPM Counts Eqauls…
rpm = (rpm_array[0] + rpm_array[1] + rpm_array[2] + rpm_array[3] + rpm_array[4]) / 5;
}

}

//Capture The IR Break-Beam Interrupt
void fan_interrupt()
{
time = (micros() - time_last);
time_last = micros(10);
}

You 'll recognize a well known piece from Pyro, but it seems something is missing…
How does this interrupt work ?

Big thanks to all !

 attachInterrupt(0, fan_interrupt, FALLING);

This will call the function fan_interrupt() each time Pin 2 goes from HIGH to LOW.

void fan_interrupt() {
   time = micros() - time_last; 
   time_last = micros();
}

This stores the time (in microseconds) between falling edges of Pin 2.

Note: 'time' and 'time_last" should be unsigned long, not float.

Hi John Thanks. As you explain it is much easier to understand. So the prog displays the time spent between two interrupts corresponding to one revolution of the prop. I should manage now. Why should it be a unsigned long and not a float ? Tks again

Why should it be a unsigned long and not a float ?

Because that is what the millis() function returns - the number of milliseconds since the Arduino was reset is a whole number.