Im working on a project involving a spedometer but im not getting the expected results in the tinkercad circuits simulation..
The circuit is simplified down to two components, a function generator (used instead of a hall trigger) to simulate a wheel rotation detection, and a arduino.
I shared the circuit in question below, so feel free to check it out and see if you can make sense of it, because i sure cant..
Now, if a wheel circumference (variable name "cirq" in the code) is set to 2114 mm, and the function generator is set to 1Hz (one wheel rotation per second), the speed SHOULD be 7.6104 km/h, but the simulator returns 7.2km/h.
if the frequency is increased to 2Hz, the result is 14.4km/h, but should be 15.2208km/h.
Now, if we change the "cirq" to 2000(mm), the simulator suddenly reports expected speed, 7.2km/h @ 1Hz and 14.4km/h @ 2Hz.
But the simulator fails if the cirq is anything more precies than increments of 1000.
Also, the simulator fails to calculate correct speed if the function generator is set to 1.5Hz or some other decimal number..
So am i doing something wrong here? Is my code incorrect or is it the simulator that is misbehaving?