I will be happy to show the code when I have a working code.
I asked the question - hoping that someone who allready have done the considerations could give me som info.
I have Googled for ideas and all the codes I have found are based on itming controlled by interupts.
Thats why I feel I am on the wrong track by going for a solution based on pulsIn.
There are a few ways to measure the RPM, but in principle you will measure the time between two pulses from the IR-sensor. Less pulses means more accuracy but it will take a long time to see what happens when you change the RPM.. I would suggest to have about 5 pulses per rotation.
Trigger an interrupt can work fine.. The rest of the time can be used to calculate and create the right info for the display. And don't display more than 1 digit behind the comma.. It will fluctuate too much.. Maybe calculate the average over the last four or five measurements gives you a more relaxed display.
Is it one pulse per revolution? If the speed is stable, using pulseIn(pulsePin, HIGH) + pulseIn(pulsePin, LOW) should get you the total time for one revolution.
There are 60 million microseconds in a minute. unsigned RPM = 60000000ul / (pulseIn(pulsePin, HIGH) + pulseIn(pulsePin, LOW));
Warning: If the turntable is stopped, both of the pulseIn() calls will time out and return zero. Dividing by 0 is a problem so you should check for timeout first: