problem with a sweep and array schetch.

Hello, I have been putting togeather a code from the “examples/servo/sweep” schetch which comes with the Arduino Software and a “array” schetch I found somewhere. It is now working but there is one small thing I cant figure out. In the orginal “sweep” schetch I can controle how many “steps” the servo motor connected to the board takes. But I cant make it happend in the code I have cooked up. First I show you the orginal “sweep” schetch and then the one i have cooked. What do I do wrong?

Best

Ingirafn

Sweep schetch.

// Sweep
// by BARRAGAN http://barraganstudio.com
// This example code is in the public domain.

#include <Servo.h>

Servo myservo;

int pos = 0;

void setup()
{
myservo.attach(9);
}

void loop()
{
for(pos = 30; pos < 70; pos += 1) //Here I belive it the code that makes it take one step at a time “pos +=1”
{
myservo.write(pos);
delay(200);
}
for(pos = 70; pos>=30; pos-=1)
{
myservo.write(pos);
delay(200);
}
}

My schetch.

#include <Servo.h>

Servo myservo1;
Servo myservo2;

int pointx = {50, 10, 50, 90, 50};
int pointy = {10, 50, 90, 50, 10};
int pos = 0;

void setup()
{
myservo1.attach(10);
myservo2.attach(9);
}

void loop()
{
for(int i=0; i<6; i=i+1)
{
myservo1.write(pointx*);//pos+= 10; //Here I am trying to control how many steps the servo will take before delay.*
delay(100);
}

  • for(int i=0; i<6; i=i+1)*
    {
    myservo2.write(pointy*); //pos += 10;*
    *delay(100); *
    }
    }

What are the 6 iterations of this loop supposed to do? The loop index is not referenced in the loop.

What is the relationship between pointx and pos? You are moving the servo to one and incrementing the other.

for(int i=0; i<6; i=i+1)
{                                 
 myservo1.write(pointx);//pos+= 10; //Here I am trying to control how many steps the servo will take before delay.
delay(100);
}

Hey Ingi, can I ask where the spelling of "schetch" comes from? Is it Schetchoslovakian? Or Schetchnyan? :)

I know I'm playing with words here, but I'm seriously interested to know. I figured it must be the equivalent of "sketch" in another language. Thanks.