Hardware to measure velocity via string/wire attatchment? beginner
This is an example of the optical encoder.
You want to use interrupt detection, rather than polling.
Or maybe even an HW counter.
That's all you really need.

I am using 4 of them for a car.

I am in the process of refactoring the code, but you could already have a look at the driver &amp; example I wrote for ChibiOS, here.