Society of Robots - Robot Forum
Software => Software => Topic started by: darth on September 26, 2011, 06:20:45 AM
-
hi.
i wanna run 2 servo motors that are connected to my arduino uno. i just wanna know basic program to move servo frwd, back, right and left that will work while i am using ardino0022 software from arduino.cc site in windows.
-
Hi darth,
To move the robot forward use the following code
#include <servo.h>
Servo servo1; //defining a servo
Servo servo2;
void setup()
{servo1.attach("pin number"); //type the pin in which you want to attach ur servo
servo2.attach("pin number"); //type the pin dor servo 2
}
void loop()
{ servo1.write(position) ;//enter the servo position..ie b/w -180 and +180.
servo2.write(position);
}
Depending on the position you enter the robot will move forward, backward etc.