We attached a magnet (actually two) onto the wheel.
We used a hall effect sensor to count the revolutions of the wheel.
const int hePin = 4;
bool heState = 0;
unsigned long time;
const unsigned long fixedTime = 1000;
void setup()
{
Serial.begin(9600);
}
int count()
{
int count=0;
boolean flag=LOW;
unsigned long curTime=0;
unsigned long startTime=millis();
while (curTime<=fixedTime)
{
if (!digitalRead(hePin)==HIGH)
{
flag=HIGH;
}
if (!digitalRead(hePin)==LOW && flag==HIGH)
{
count++;
flag=LOW;
}
curTime=millis()-startTime;
}
Serial.print(count);
Serial.print(" ");
int count2rpm = int(60000./float(fixedTime))*count;
return count2rpm;
}
void loop()
{
int rpm = count();
Serial.print("rpm: ");
Serial.println(rpm);
}
Reference:https://sites.google.com/site/measuringstuff/more-sensor-examples

