Go Down

### Topic: circle code for Etch a sketch? (Read 1 time)previous topic - next topic

#### spinjim

##### Sep 30, 2007, 12:16 am
I am just learning arduino and electronics so I built a computer controlled etch a sketch. Not very original I know, but a good way to learn. All I used was 2 stepper motors (Jameco #155432) and 2 darlington arrays (uln 2004) a powers supply and the arduino board. I have been successful at programming it to a point. I first made straight lines, then boxes, then diagonals and then diamond shapes but I am stuck on how to make a circle. Can anybody out there offer some help to the mathematically challenged?
I want to draw images too, but that is after I learn how to do circles. I included some simple code that will make a diagonal line.
Thanks,

Code: [Select]
`// positive hor steps will move right, negative left aproximatly 1720 steps from side to side// positive ver steps will move up, negitive down. Aproximatly 1150 steps bottom to top// the acuracy is not very good. Mechanically the stylus is controlled by strings that stretch and give instead of breaking.#include <Stepper.h>#define STEPS 200Stepper hor(STEPS, 2, 3, 4, 5);Stepper vert(STEPS, 8, 9, 10, 11);int rpm=30;void setup(){// set the speed of the motor to the variable rpm  hor.setSpeed(rpm);  vert.setSpeed(rpm);} void loop(){  // draw a diagonal line for (int i=0; i <= 800; i++){    hor.step(1);  vert.step(1);   }}`

#### westfw

#1
##### Sep 30, 2007, 01:52 am
Look up "Bresenham circle"

#### hungerburg

#2
##### Oct 02, 2007, 12:19 pm
there "http://www.mikrocontroller.net/topic/42447#610705" is an implementation of Bresenham for a full circle - its not perfect for small circles though

Go Up

Please enter a valid email to subscribe

To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy