//Variables
float value=0;
float rev=0;
int rpm;
int oldtime=0;
int newtime;

void isr() //interrupt service routine
{
rev++;
}

void setup() {
  Serial.begin(115200);
  attachInterrupt(digitalPinToInterrupt(13),isr,RISING); //attaching the interrupt
}

void loop() {
  delay(1000);
  detachInterrupt(0); //detaches the interrupt
  newtime=millis()-oldtime; //finds the time 
  int wings= 3; // no of wings of rotating object, for disc object use 1 with white tape on one side
  int RPMnew = rev/wings; //here we used fan which has 3 wings
  rpm=(RPMnew/newtime)*60000; //calculates rpm
  oldtime=millis(); //saves the current time
  rev=0;
  Serial.print("rpm:");
  Serial.println(rpm);
  attachInterrupt(digitalPinToInterrupt(13),isr,RISING);
}