Hall effect sensor skipping pulses at high speed

Hello, I'm trying to build an odometer for my electric scooter using the code and wiring from alan_dewindt's odometer setup. At low speeds the arduino seems to be picking up the digital pulses from the hall effect sensor module, but at higher speeds the arduino seems to be skipping readings from the sensor and outputting a slower speed on the LCD. Even at full speed the light on the sensor appears to be blinking in time with the revolutions of the wheel so I don't think the sensor is the problem. I've tried two different setups with the same wiring - one uses a Nano and the other uses an Uno. I'm pretty sure they are fakes since I got them for cheap on ebay, but I've never had any problems with either of them. I created a sketch that displays the digital output of the hall effect sensor which shows the arduino skipping readings.

I would really like to keep the functionality of his code since I am not particularly very experienced at arduino programming. I have modified his code but only to change the wheel circumference to 0.495m. Hopefully this is a simple fix. I really want to be able to know how fast my scooter goes!

alan_dewindt's odometer setup: https://create.arduino.cc/projecthub/alan_dewindt/bicycle-odometer-and-speedometer-with-99-lap-period-recorder-331d2b

My hall effect sensor:https://www.ebay.com/itm/2PCS-3144E-Hall-Effect-Sensor-Switch-Speed-Counting-Sensor-Magnetic-Detector-RF/323790631863?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649&autorefresh=true

My troubleshooting sketch which displays the output of the hall sensor in the serial plotter:

int sensorPin = 13;    // select the input pin for the potentiometer
int sensorValue = 0;  // variable to store the value coming from the sensor
 
void setup() {
  // begin the serial monitor @ 9600 baud
  Serial.begin(9600);
}
 
void loop() {
  // read the value from the sensor:
  sensorValue = digitalRead(sensorPin);
 
  Serial.println(sensorValue);
  Serial.print(" ");
 
  delay(20);
}

I have attached an image of the serial plotter with the gaps in the sensor reading as well as a picture of my arduino uno setup which I used to plot the hall sensor output.

20200406_215203[1].jpg

here is your problem

  delay(20);

you don't want to use delay(), unless you allot 'interrupt' pin to sensor

The delay() in combination with the Serial.print() statements are an issue.

Look at the state change detection example, so you can record the change of the signal of the sensor - that's when a rotation has been completed, and the blink without delay example, which is the technique you need to print a bit less frequent. Though printing upon each state chance should also work well. A rotating wheel giving one pulse per rotation is not at all high speed for an Arduino.

Thanks for the responses. Removing the delay in the troubleshooting sketch has fixed the skipping problem in the serial monitor. I'm guessing the skipping was caused by the sensor falling then rising while the arduino was in it's 20 millisecond delay. I will look for a similar delay in alan_dewindt's code and play around with it as well as do some reading up on interrupts and such since I am a noob at arduino.

Chances are using interrupts give you way more trouble than it solves for you. For slow signals like this you don't need interrupts.
The other thing you should not use is the delay() function. Check out the Blink Without Delay sketch on how it's done without, keeping your program responsive.