I have a dc motor and h-bridge which I'd like to control by an analogRead along a series of ten 200 ohm resistors. Picture a model train traveling down a track and every 2 inches it reads a value from the resistors in series. I can read the voltage and divide by 100 to determine the resistor "number".
I want to use the sensed number to advance the train to the next position; analogRead +1.
The problem is that analogRead creates a infinite loop. I read resistor 2 and add 1, but the sensor reads 3 and adds 1, then 4...
Is there a way to stop a motor after it has advanced one resistor?