const int numberOfEntries = 64; // the max number of pulses to measure
To:
const int numberOfEntries = 2; // the max number of pulses to measure
Then I do get an accurate readings, mostly. But when the times get shorter, around 5ms, then the calculations get again wrong. Could the hardware interrupt disturb the software operation?
Update:
Generally it's a good idea to stick to simpler code that one can understand. Now I use the pulseIn() function and so far it works better: