with the Sparkfun inventor kit there is a circuit that controls a single servo with arduino. based on this code i want to build a robot, But i am having trouble understanding the underlined part of the code at the very bottom

/*SparkFun Inventor's KitExample sketch 08

Servo servo1; // servo control object

void setup(){ // We'll now "attach" the servo1 object to digital pin 9. // If you want to control more than one servo, attach more // servo objects to the desired pins (must be digital).

// Attach tells the Arduino to begin sending control signals // to the servo. Servos require a continuous stream of control // signals, even if you're not currently moving them. // While the servo is being controlled, it will hold its // current position with some force. If you ever want to // release the servo (allowing it to be turned by hand), // you can call servo1.detach().

servo1.attach(9);}

void loop(){ int position;

// To control a servo, you give it the angle you'd like it // to turn to. Servos cannot turn a full 360 degrees, but you // can tell it to move anywhere between 0 and 180 degrees.

// Change position at full speed:

servo1.write(90); // Tell servo to go to 90 degrees

delay(1000); // Pause to get it time to move

servo1.write(180); // Tell servo to go to 180 degrees

delay(1000); // Pause to get it time to move

servo1.write(0); // Tell servo to go to 0 degrees

delay(1000); // Pause to get it time to move

// Change position at a slower speed:

// To slow down the servo's motion, we'll use a for() loop // to give it a bunch of intermediate positions, with 20ms // delays between them. You can change the step size to make // the servo slow down or speed up. Note that the servo can't // move faster than its full speed, and you won't be able // to update it any faster than every 20ms.

// Tell servo to go to 180 degrees, stepping by two degrees

for(position = 0; position < 180; position += 2) { servo1.write(position); // Move to next position delay(20); // Short pause to allow it to move }

// Tell servo to go to 0 degrees, stepping by one degree

for(position = 180; position >= 0; position -= 1) { servo1.write(position); // Move to next position delay(20); // Short pause to allow it to move }}

I THINK I NEED TO REPRASE THIS QUESTION. MY NEW QUESTION IS, WITH THE UNDERLINED CODE I DONT UNDERSTAND THE CODE AND WHAT MEANS WHAT TO ARDUINO. I AM MAKING A ROBOT AND I WANT TO USE SERVOS, HOWEVER THAT UNDERLINED CODE IS WHAT CONTROLS SPEED BUT I DONT UNDERSTAND HOW TO CONTROL THE SPEED WITH THAT CODE FORMAT. I HOPE YOU CAN UNDERSTAND MY QUESTION THANKS IN ADVANCE

I THINK I NEED TO REPRASE rewrite THIS QUESTION without all the shoutiness.

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.Do not send technical questions via personal messaging - they will be ignored.I speak for myself, not Arduino.

What your undelined code is doing is going from 0 to 180 in steps of 2 degrees... Each servo1.write(position) is 2 degrees further than the last write, since the for's position += 2 is incrementing in 2's. (Zoomcat's is similar, but in 1's). BUT, each pass through the for also includes a delay(20) (or 15 in zoomcat's example) which causes a pause of 20ms between each 2 degree movement step.

Without that loop and delay, if the servo was at say 0 degrees and you sent it a servo1.write(180) it would have gone from 0 to 180 as fast as it was able. Servo speed is quoted by the makers as the time to move through 60 degrees, such as 0.16 seconds for this one. (That's the speed with no load, obviously slower when it's trying to move something.)