Spiral movement using X,Y motors

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

#include <Servo.h>

Servo servox;
Servo servoy;

long i;
unsigned long timer;
unsigned long timer2;

void setup()
{
servox.attach(9);
servox.write(90);
servoy.attach(10);
servoy.write(90);

pinMode(8, OUTPUT);
analogWrite(8, 128);

delay(300);
timer = millis()+90000000; // restored O.V.
timer2 = millis()+360000000; // restored O.V.

}

void loop()
{
float r1 = random (.1,10); // added
int r2 = random (10,130); // added
int r3 = random (50,300); // added

if(millis() > timer){
digitalWrite(5, LOW);
servox.write(90);
servoy.write(90);
servox.detach();
servoy.detach();
if(millis() > timer2)
{
timer2 = millis()+3600000;
timer = millis()+900000;
servox.attach(9);
servoy.attach(10);
servox.write(90);
servoy.write(90);
pinMode(8, OUTPUT); // was 5
analogWrite(8, 128); //was 5
delay(r3); // was 300900000
}
}
if(millis() < timer){

int CircleXCenter = 90;
int CircleYCenter = 90;
int loopDelay = r3; // was 30

randomSeed(analogRead(4));
CircleXCenter = random(80,100);
randomSeed(analogRead(5));
CircleYCenter = random(80,100);
randomSeed(analogRead(6));
loopDelay = random(r1,r2); // was 15, 30

for (int Rad = 5; Rad < 30; Rad++)
{
for (int i = 0; i > 5; Rad ++)
{
for (int i = 100; i > 0; i--)
{
float angle = i23.14/100;
int xPos = CircleXCenter + (cos(angle) * Rad);
int yPos = CircleYCenter + (sin(angle) * Rad);

servox.writeMicroseconds(xPos);
servoy.writeMicroseconds(yPos);
delay(loopDelay);

}
}
}
}
}

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

#include <Servo.h>

Servo servox;
Servo servoy;

long i;
unsigned long timer;
unsigned long timer2;

void setup()
{
  servox.attach(9);
  servox.write(90);
  servoy.attach(10);
  servoy.write(90);
 
  pinMode(8, OUTPUT);
  analogWrite(8, 128);
 
  delay(300);
  timer = millis()+90000000; // restored O.V.
  timer2 = millis()+360000000; // restored O.V.

}

void loop()
{
float r1 = random (.1,10); // added
int r2 = random (10,130); // added
int r3 = random (50,300); // added

if(millis() > timer){
      digitalWrite(5, LOW);
      servox.write(90);
      servoy.write(90);
      servox.detach();
      servoy.detach();
      if(millis() > timer2)
      {
            timer2 = millis()+3600000;
            timer = millis()+900000;
            servox.attach(9);
            servoy.attach(10);
            servox.write(90);
            servoy.write(90);
            pinMode(8, OUTPUT); // was 5
            analogWrite(8, 128); //was 5
            delay(r3); // was 300900000
      }
}
if(millis() < timer){

int CircleXCenter = 90;
int CircleYCenter = 90;
int loopDelay = r3; // was 30

randomSeed(analogRead(4));
CircleXCenter = random(80,100);
randomSeed(analogRead(5));
CircleYCenter = random(80,100);
randomSeed(analogRead(6));
loopDelay = random(r1,r2); // was 15, 30

for (int Rad = 5; Rad < 30; Rad++)
    {
      for (int i = 0; i > 5; Rad ++)
      {
          for (int i = 100; i > 0; i--)
          {
          float angle = i23.14/100;
          int xPos = CircleXCenter + (cos(angle) * Rad);
          int yPos = CircleYCenter + (sin(angle) * Rad);
         
          servox.writeMicroseconds(xPos);
          servoy.writeMicroseconds(yPos);
          delay(loopDelay);
         
          }
      }
    }
}
}

You need to tell us what the program actually does and what you want it to do that is different

And see how code should be presented using the code button </>

...R

New question split from an ancient thread

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile: