Stop

Here we have a code that makes a blob shape, we wish it to stop after two rotations of the code loop and are not sure how to do this? Some people suggested to use servo detach? But we are not sure how to use that in our code or even if that is a good idea.

Here is the code so far

#include <Servo.h>

Servo servoLeft; // Define left servo
Servo servoRight; // Define right servo

void setup() {
servoLeft.attach(11); // Set left servo to digital pin 10
servoRight.attach(9); // Set right servo to digital pin 9
}

void loop() { // Loop through motion tests

stopRobot();
delay(500);
sshapeattempt();
delay (500);
curvey ();
delay(500);
curveytwo();
delay(500);
stopRobot();
delay(500);
sshapeattempt();
delay (500);
curvey ();
delay(500);
curveytwo();
delay(500);

}

void stopRobot() {
servoLeft.write(155);
servoRight.write(81);

}

void sshapeattempt(){
servoLeft.write(81);
servoRight.write(155);
}

void curvey(){
servoLeft.write(155);
servoRight.write(155);

}
void curveytwo(){
servoLeft.write(81);
servoRight.write(81);

}

Hi,

Here we have a code that makes a blob shape, we wish it to stop after two rotations of the code loop and are not sure how to do this? Some people suggested to use servo detach? But we are not sure how to use that in our code or even if that is a good idea.

How does it make a blob shape?
What servo's?

Please read your posting as if you were someone who has no idea about your project.

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7 http://forum.arduino.cc/index.php/topic,148850.0.html

And a picture of your project so we can see what you are talking about.

Thanks.... Tom... :slight_smile:

Are these standard servos or continuous-rotation?
Tom's suggestion of a picture of your project is a very good idea. It's very hard to imagine how the code creates a blob shape, without seeing the machine/robot. What is it exactly?

I can't begin to fathom how this:-

servoLeft.write(155);
servoRight.write(81);

stops the "robot", and how this:-

servoLeft.write(81);
servoRight.write(155);

creates an 'S' shape.