new to arduino

hello all

Please bare with me am i new to playing with arduino

im using the servo sweep code from the libraries,
what i was wondering is how do i add a stop delay into the loop in between the left and right movement

// Sweep
// by BARRAGAN <http://barraganstudio.com> 

#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
                // a maximum of eight servo objects can be created 
 
int pos = 0;    // variable to store the servo position                                         (this was 0)
 
void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
} 
 
 
void loop() 
{ 
  for(pos = 0; pos < 110; pos += 1)  // goes from 0 degrees to 180 degrees                     ( this was 0 & 180 )
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(50);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 110; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(50);                       // waits 15ms for the servo to reach the position 
  } 
}

many thanks jason

...how do i add a stop delay into the loop in between the left and right movement?

You just... add it :slight_smile:

Have a look at the delay function.

// Sweep
// by BARRAGAN <http://barraganstudio.com>

#include <Servo.h>

#define DELAY 1000

Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position                                         (this was 0)

void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}


void loop()
{
  for(pos = 0; pos < 110; pos += 1)  // goes from 0 degrees to 180 degrees                     ( this was 0 & 180 )
  {                                  // in steps of 1 degree
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(50);                       // waits 15ms for the servo to reach the position
  }

  //just add a delay :)
  delay(DELAY);

  for(pos = 110; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  {
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(50);                       // waits 15ms for the servo to reach the position
  }
}

thankyou very much alphaBeta

that was easy when you know how