Hi PaulS,
I got that from here.
http://forum.arduino.cc/index.php?topic=92624.0
I think the point of him putting the two is for the debounce mechanism. In my case, if I use FALLING would a code like this work?
byte revolutions;
unsigned int rpmilli;
float speed;
unsigned long timeold;
float wheel_circ = 1.634;
void setup()
{
Serial.begin(9600);
attachInterrupt(0, rpm_fun, FALLING);
revolutions = 0;
rpmilli = 0;
timeold = 0;
}
void loop()
{
if (revolutions >= 10) {
//Update RPM every 10 counts
// calculate the revolutions per milli(second)
rpmilli = revolutions/(millis() - timeold);
timeold = millis();
revolutions = 0;
speed = rpmilli * wheel_circ/ 1000; // speed in meters per second
speed = 2.237*speed; // speed in miles per hour
Serial.print(" Speed:");
Serial.print(speed,DEC);
Serial.println(" mph");
}
}
void rpm_fun()
{
revolutions++;
}
For now I don't have a wheel or rotating object which I can attach my magnet to, but I tried periodically bringing the magnet close to the hall sensor and it keeps showing me 0.0000000000 mph in my COM port :~