Coding two servos

I can't seem to code for two servos I have an ATmega 2560 can some one pls show me the code

Hi,
Can you code for one servo.
Check out the arduino IDE Examples.

What is your electronics, programming, arduino, hardware experience?

Tom.... :slight_smile:

Hope this will help you................

#include <Servo.h>

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

int pos = 0; // variable to store the servo position

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

void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; 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
}
myservo.detach();
////////////////// for second servo////////////////
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo1.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo1.write(pos); // tell servo to go to position in variable 'pos'
delay(50); // waits 15ms for the servo to reach the position
}
myservo.detach();

}

Hi,
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

Tom.... :slight_smile: