Confused by oscilloscope - square wave signal to RPM

Yes. That's a better idea.

  1. Change the code to only look for rising edges.
  2. Use a median filter to ignore spurious readings.