I tried the following example but could not see the output on serial monitor:
(just pasting the relevant lines)
void setup()
{
Serial.begin(9600);
attachInterrupt(0, rpm_fun, RISING);
}
void loop()
{
if (half_revolutions >= 20) {
rpm = 30*1000/(millis() - timeold)*half_revolutions;
timeold = millis();
half_revolutions = 0;
Serial.println(rpm,DEC);
}
}
void rpm_fun()
{
half_revolutions++;
//Each rotation, this interrupt function is run twice
}