Revolutions Per Minute Calculating Error

It is possible that you are counting multiple times each time the sensor is triggered, as the code will execute very fast.

You need to include some form of trigger detection. This is done by remembering if the digital input was low or high the last time you checked and only counting the low to high (or high to low) transitions.

A relatively straightforward way to do this is to use an interrupt that will be triggered on the transition only - there is lots of stuff on hte board on how this can be done.