I have a track based robot powered by a twin gearbox and two dc motors. I want it to move along a preprogramed path and end up back at the same spot, requiring more than a few precise right angle turns. I thought this would be an easy thing to accomplish but it's been mostly frustrating.
I thought I could just use code like this:
digitalWrite(H1,LOW); //H-bridge running Motor 1 forward
digitalWrite(H2,HIGH); //H-bridge running Motor 2 backward
analogWrite (Motor2,100); //motor speed
analogWrite (Motor1,100); //motor speed
delay(1400); //a smaller number here results in a smaller angle, large in a larger angle
but the result has been spotty at best. If getting the number right wasn't difficult enough, everything from the conditions of the treads to the little imperfections in the driving surface change how the thing turns. Even when working on the flattest and smoothest surface I have, the results are inconsistent and the whole project kind of falls apart if the pathing isn't working properly.
Is there another realistic solution that would provide me anything close to consistent movement?