Skip to content

Instantly share code, notes, and snippets.

@dustynrobots
Created August 23, 2012 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dustynrobots/3440029 to your computer and use it in GitHub Desktop.
Save dustynrobots/3440029 to your computer and use it in GitHub Desktop.
This is code we'll use to set both motors in the robotic arm to a specific position
#include <Servo.h>
Servo ShoulderServo; // create servo object to control a servo
Servo ElbowServo; // create servo object to control a servo
int elbowPos; // variable to store the servo position
int shoulderPos; // variable to store the servo position
void setup()
{
ShoulderServo.attach(5); // attaches the servo on pin indicated to the servo object
ElbowServo.attach(3); // attaches the servo on pin indicated to the servo object
}
void loop()
{
elbowPos = 140; // strike a pose position
ElbowServo.write(elbowPos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
shoulderPos = 80; // strike a pose position
ShoulderServo.write(shoulderPos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment