Programming servos to move laser pointer in circle: help needed

Hi, sorry for my english.

I needed to move 2 servos for drawing a circle.

Here, they were solved SOLVED:Programming servos to move laser pointer in circle: help needed - Programming Questions - Arduino Forum

BUT, i need to begin Servo Y a little more up. I need to put center point X=90 Y=120

Is possible?

Thank you!!

1 Like

jagvalles:
Is possible?

Yes

The original code had this:

      float j = 20 * (cos ((3.14 * i)/180)) + 90;
      float k = 20 * (sin ((3.14 * i)/180)) + 90;

You could have changed it to something like this and tried it:

      float j = 20 * (cos ((3.14 * i)/180)) + 90;
      float k = 20 * (sin ((3.14 * i)/180)) + 120;

faster than using this forum and waiting for answers.

Have you ever looked at the Bresenham algorithms, for drawing lines and circles?

Thak you for your answers!

float j = 20 * (cos ((3.14 * i)/180)) + 90;
float k = 20 * (sin ((3.14 * i)/180)) + 120;

This is what i tried, but the circle is deformating in vertical axis.

Now i have begun to read about Bresenham algorithms (thaks DrDiettrich)

Regards!!

jagvalles:
float j = 20 * (cos ((3.14 * i)/180)) + 90;
float k = 20 * (sin ((3.14 * i)/180)) + 120;

floating point maths and using sin/cos/tan on arduino adds a lot of program memory usage.
Depending on the range of i, you could form LUTs for the j and k values, having an array as the LUT?

The original +90 looked to be setting the servos to middle position so they can travel to either side for the distance of radius.
That's why your +120 is wrong. That servo isn't starting middle and runs out of range.

Most servos can go 10 degrees to 170 degrees or better. Are you saying that this one cannot reach 140 degrees?

I suspect that something else is wrong.