I have been measuring the RPM of a few AC devices like (Juicers, Mixer\grinders etc) using an IR led attached to a coin cell(which is connected to the rotating arm of the appliance) and a photodiode connected to the arduino.
Although my RPM count is coming out to be pretty accurate, i have observed that the IR led and photodiode pair interacts for more time than I want. Which leads me to a suspicion that the calculated RPM may be more than the actual.
Please suggest how to use ir led + photodiode as a reliable sensor.
Following is my arduino code:
int SensePin = 04;
int RotationCount=0;
// the setup function runs once when you press reset or power the board
void setup() {
Serial.begin(9600);
pinMode(SensePin, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
int sensorValue;
digitalWrite(SensePin,HIGH);
sensorValue = analogRead(A0);
if (sensorValue < 1023)
{
RotationCount++;
Serial.println(RotationCount);
delay(3); // dirty fix to sense ir led+photdiode only once
}
}