SOLVED:Programming servos to move laser pointer in circle: help needed

Hello all.
New to Arduino and programming but so far I've made most of my functions work.
I am making a laser pointer cat toy and hope to be able to control it over the internet as I already have a webcam in my room. That is WAY above me at this point.
Anyway, with the help of some 3d modeling software and a 3d printer, I'm making a fixture to hold the servos, laser, board and all other electronics. Until that is all printed up, I'm working on the code.

The problem I'm having is making the Arduino plot points around the circle and then assign those coordinates to the servos. Since the servos move from 0 to 180, I'm using 90 degrees as my zero point, so (90,90) would be the origin of the graph.
I would like to plot a circle of radius 20, so the range of each servo is from 70 to 110 degrees.

My first attempt was this:

for(int i=0; i<=359; i++){
servoX.write(20 * cos (i) + 90);
servoY.write(20 * sin(i) +90);
delay(100);
}

So to sum this up, a FOR loop starts at 0 degrees and stops at 359, increments by one degree.
At each value of i (degrees around the circle) take the cos/sin respectively, multiply by 20 (because thats the radius I want to use) and add 90 degrees to it for the offset of the servo.
When executed, they both kind of move back and forth MANY times.

I've tried some degree-> radian conversions with no luck either.

Any help is appreciated!

If it were me, I'd create a couple of variables equal to your X and Y functions and print them to see what values you are actually writing to the servos. I think that would tell you a lot.

A friend of mine suggested that. I got it to print the values and they were all funky and a lot of them were repeats.

Hint: the sin() and cos() functions take a float as the parameter, expressed in radians:

http://arduino.cc/en/Reference/Sin
http://arduino.cc/en/Reference/Cos

I figured they would float eventually to some decimal place (like 12) but how do I apply that to my code?

From "The Arduino Cookbook":

Discussion
Angles are specified in radians and the result is a floating-point number.
The following example illustrates the trig functions:
float deg = 30; // angle in degrees
float rad = deg * PI / 180; // convert to radians
Serial.println(rad); // print the radians
Serial.println sin(rad)); // print the sine
Serial.println (cos(rad)); // print the cosine
This converts the angle into radians and prints the sine and cosine. Here is the output
with annotation added:
0.52 30 degrees is 0.5235988 radians, print only shows two decimal places
0.50 sine of 30 degrees is .5000000, displayed here to two decimal places
0.87 cosine is .8660254, which rounds up to 0.87

Thanks for the replies.

My question is then this: if I say sin(30), does Arduino think I'm telling it to find the sin of the angle in radians or degrees?

It doesn't think, it knows only radians

I'm not near my Arduino to test this but does this look right?

for(int i=0; i<=360; i=i++){
      float j = 20 * (cos ((3.14 * i)/180)) + 90;
      float k = 20 * (sin ((3.14 * i)/180)) + 90;
      servoX.write(j);
      servoY.write(k);
      Serial.print(j);
      Serial.print(",");
      Serial.println(k);
      delay(100);

To sum up:
take i, convert to radians, take sin/cos of, then multiply by R and add 90?

for(int i=0; i<=360; i=i++){
for(int i=0; i<=360; i++){

Looks better

Right, thanks.
I usually do. I've changed it from i=i+5 to i++ and back several times so sometimes I get mixed up.

3.14

That's a pretty poor approximation for pi.

Considering I'm floating the whole equation to 2 decimal places, I figure it will work.

IT WORKED. Thanks for all the help.

// I TRIED TO DRAW WITH ROBOT ARM WITH THREE 180 degree SG90 Servo Motors

#include <Servo.h>

Servo servox; Servo servoy; Servo servoz;
long i;

void setup()
{
Serial.begin(9600);
servoy.attach(10); //BOTTOM
servox.attach(9); //LEFT
servoz.attach(11); //RIGHT
}

void loop()
{
int CircleXCenter = 180; //LEFT
int CircleYCenter = 90; //BOTTOM
int loopDelay = 25;
int Rad = 60;
int zPos = 60;

//for (int i = 0; i < 200; i++) //AntiClockwise direction

for (int i = 300; i > 0; i--) //Clockwise direction
{
float angle = i23.14/100;
int xPos = CircleXCenter + (cos(angle) * Rad); //LEFT GREEN-PLOT
int yPos = CircleYCenter + (sin(angle) * Rad); //BOTTOM BLUE-PLOT

servox.write(xPos); Serial.print("X : "); Serial.print(xPos); Serial.print(" | ");
servoy.write(yPos); Serial.print("Y : "); Serial.print(yPos); Serial.print(" | ");

Serial.print("ANGLE : "); Serial.println(angle);
servoz.write(zPos);
delay(loopDelay);
}
}