degree

I have a robot with 2 continuous rotation servos as wheels. when it needs too turn (obstacle from ping sensor) it puts 1 wheel forward and 1 wheel backwards resulting in turning. now when it's turning how do i figure out how much it has turned for example 90 degrees right now I am setting the servos and delaying it for a second or 2 to make it turn but this is not perfect since it goes slower on carpet than tile

is there a sensor or a math problem that i can use to get the degrees turned?

If you consider no slip between wheel and floor then fit a perforated disk to act as a turns counter to the drive wheels. Or if price is no object, fit a compass module such as HMC6352

Hi arduinopi,

To do this accurately, you would need rotation sensors on each wheel.

Typical sensors for this have a disc with slots or holes in it, and an Infrared LED shining across at a phototransistor. Often these are combined in a small "OptoInterrupter" device. Here's an example:
http://arduino-direct.com/sunshop/index.php?l=product_detail&p=202
or
http://www.emartee.com/product/42035/Mini%20Motor%20Speed%20Sensor%20%20A
another example:
http://www.ebay.com/itm/Arduino-Wheel-Encoder-Watcher-Kit-4WD-3PA-Robot-Car-/160646476045?pt=LH_DefaultDomain_0&hash=item256746b10d#ht_4586wt_1344

DISCLAIMER: Mentioned stuff from my own shop...

The circumference of a circle is given by the formula Pi x D
Where Pi=3.14 and D is the diameter of the circle.

So if the diameter of your wheel is 2cm then its circumference is 3.14 x 2 = 6.28cm.
This means if your wheel makes one revolution it will travel 6.28cm (if it does not slip).

Assuming your robot is turning on the spot, then the robot wheels will be driving round a circle on the floor.
The diameter of that circle will depend on how far apart the wheels are.

To turn 90 degrees your wheels will have to drive 1/4 of the way round the big circle on the floor.
So you calculate the circumference of the big circle, divide it by 4 then divide that by the circumference of your wheels to work out how many times you have to make them turn to move the robot through 90 degrees.

Another way to work things out is to put a mark on the wheel, turn the robot through 90 degrees and count how often the wheel has to go round.