Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Arduino Uno Controlling 3 RC-type Servos at a Time

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
256 views
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Aug 6, 2011

This was very easy to connect and program. Hardware includes:
1) Arduino Uno board
2) Yourduino Sensor Shield expansion board
3) Three servos from different vendors: A high quality Futaba, one from Electronix Express, and one from Solarbotics

The servos plug directly into the Sensor shield board, which is nice.

The program was very easy to write. I'll include it here for those curious, with the disclaimer that it has room for cleanup. Especially note that YouTube would not allow greater than or less than symbols, so I've replaced them with tilde and double-tilde, respectively. You'll need to change them back before this program will run:

/*
Servo Test Program

Sweeps 3 different servos back and forth at the same time. This example code is based on stuff already in the public domain. Servo is attached to pins 3, 5, and 6. Servo connector follows digital I/O pinout on sensor shield: Black or brown = Ground Red = +5 VDC White, yellow, or orange = Signal
*/

#include ~Servo.h~~

Servo myservo3; // create servo objects to control servo s
Servo myservo5;
Servo myservo6;




int ServoPosition3 = 0;
int ServoPosition5 = 0;
int ServoPosition6 = 0;

void PrintPosition() {
Serial.print("Motor position is: ");
Serial.print(ServoPosition3); Serial.println(" degrees.");
}

void setup() { myservo3.attach(3); // attaches the servo on pin 3 to the servo object
myservo5.attach(5); // attaches the servo on pin 5 to the servo object
myservo6.attach(6); // attaches the servo on pin 6 to the servo object // start serial port at 9600 bps:
Serial.begin(9600);
}

void loop() {
ServoPosition5 = 185 - ServoPosition3;
ServoPosition6 = ServoPosition3;
myservo3.write(ServoPosition3); // tell servo to go to position in variable 'ServoPosition'
myservo5.write(ServoPosition5);
myservo6.write(ServoPosition6); PrintPosition();
delay(4); // wait for servo to move
if(ServoPosition3 == 0) { delay(1000); // wait for servo to move if moving 180 degrees
}
ServoPosition3 = ServoPosition3 + 7; // send servo to next position
if(ServoPosition3 ~~ 185) { // reset position if max. rotation reached ServoPosition3 = 0; delay(1000); // pause to let sero return
}




}

Category:

Science & Technology

Tags:

License:

Standard YouTube License

  • likes, 0 dislikes

Link to this comment:

Share to:
see all

All Comments (0)

Sign In or Sign Up now to post a comment!
Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more