I'm new to arduino and I have a project at school where I have to make a small robot consisting of two wheels connected to servo motors on a wood chassis move forward 3 feet, stop, and then move backwards 2 feet. I was wondering how to make the servos travel a certain distance before stopping. Thanks!
You'll need to have some kind of encoder to count the revolutions. The exact details of the feasibility thereof will depend on the actual hardware you have at hand.
It could be a tiny magnet sensed by a Hall effect sensor, or a slotted disk sensed optically. Probably other ways too.
Or, if the 3' and 2' values never need to be changed, you could "cheat" and just home in by trial and error on how long you need to run the motor at some speed, to travel those differences, and hard-code the values into your sketch.
But then of course if on demo day, the adjudicator says "ok, let's see it go forward 5' and back 1' instead" you'll be a a bit screwed.
I have a continuous rotation servo (and presumably that's what you have) whose RPM I measure with a tiny magnet and Hall sensor. I'm pretty sure the code came mostly from the Playground. Should be simple enough to mod to count rotations (and hence distance) rather than revs/minute.