I am trying to measure the frequency of rotation of a motor. I have a led and detector on either side of the motor. The motor has 3 arms so I get a signal 3 x the rotation. I have measured this waveform with a scope and its 20.89Hz BUT my code shows 22.95Hz. Multiplying this by 0.91 gives the the correct answer.
Any ideas why it won't read the correct frequency ?
Please follow the advice on posting code given in posting code
In particular note the advice to Auto format code in the IDE and to use code tags when posting code here as it prevents some combinations of characters in code being interpreted as HTML commands such as italics, bold or a smiley character, all of which render the code useless
Serial.print (char(82));Serial.print (char(65));Serial.print (char(58));Serial.print (freq);Serial.print (char(10)); Is this for a code obfuscation contest?
Thanks for the replies. I have changed to unsigned longs and printed the on and off times. They all add up to the reported frequency BUT I still believe it is incorrect.