Students needed to measure how fast their Hot Wheels cars went along the track, so I built several inexpensive photogates to help them.
It uses a photo transistor to detect when the car passes and can calculate the speed of the car at whatever position you put the sensor holder. A white LED was used instead of an IR LED so it was more obvious the device was on and connected properly.
The 3D printing of the photogate is optional. During the proof-of-concept phase, the prototype of the sensor and LED holder was made from hot gluing cardboard pieces together, and it worked just fine, though not very durable.
One sensor can measure relative speed of one car (assuming a typical length car).
A single photogate only measures relative speed for an individual car
Two photogates can be used to be more precise, but the distance must be measured by the time seen in the Arduino serial monitor to make the calculations.
Two gates can determine the exact speed for multiple cars
Below is an example of the single photogate and the serial output as the car passes.