Introduction: Arduino Based Serial Servo Controller

This is a simple serial controller for multiple servos based on the Arduino. (my first instructable too :) )

Most of the work in this came from getting the software to talk with the arduino and making a protocol for the data to be passed over. As for the hardware aspect all that I used was two servos (Parallax standard servo here.) A Sparkfun Arduino ProtoShield and an Arduino Duemilanove with ATMEGA328, but most of these parts can be substituted with similar items.

I thought up this project as part of a RC system, but setting up the communication took a lot of time. If anyone has any improvements, ideas, or bugs please feel free to comment.
EDIT: I wrote this awhile ago, just got to publishing it recently.

Step 1: Things You May Need...

Some things you will need to build this.
1. Arduino board (you choose)
2. two (or one) servos
3. jumper wires
4. Visual Studio 2008 Express -- link (optional)
5. Arduino IDE -- link

Sorry Linux and Apple fans, my program only runs on windows for now, but you can still manually send serial commands to the arduino without changing the code.

Step 2: Connect the Hardware.

Nothing very complex to this step.
Just connect one servo to pin 9 and the other to pin 10.

Step 3: Program the Arduino

now you can upload the sketch onto the arduino.

Here is a simple breakdown to the code:


Servo myservo; // create servo object to control a servo
Servo myservo1;

int incomingByte = 0, datacount = 0, counter = 0, ready = 0; // for incoming serial data
char data[10];
const char verify[8] = "ma11hew";
char command[3];

void setup() {
Serial.begin(38400); // opens serial port, sets data rate
Serial.println("Hi Arduino Here!");  // added to help identify the serial port

This just sets up the serial port and servos.

int i;
for(i = 0; i<180;i++)

for(i = 0; i<180;i++)

Simple sweeping movement to verify the servos work correctly.

void loop() {

ready = 0;
counter = 0;
while (1==1)
if ( != verify[counter])
if(counter == 6)
command[0] =;
command[1] =;
//if ( == ((command[1] * 12) % 8))
// {
ready = 1;
Serial.println("saved command");
counter ++;

this checks the serial buffer for the correct authorization string then grabs two bytes for the command.
the commented if statement allows for a makeshift checksum but would make manual interfacing hard.
ready can be set to 0 so commands will not be parsed such as in the case of corrupted data.

//search through commands
if (ready == 1)
if (command[0] == 'T')
command[0] = 0;
Serial.print("throttle control on pin 9 to: ");
Serial.println(map(command[1], 32, 126, 2, 180), DEC);
myservo.write(map(command[1], 32, 126, 2, 180));


if (command[0] == 'S')
command[0] = 0;
Serial.print("throttle control on pin 10 to: ");
Serial.println(map(command[1], 32, 126, 2, 180), DEC);
myservo1.write(map(command[1], 32, 126, 2, 180));


the rest of the code is to search command[] for valid commands (T or S.)
if either match it takes the next byte and sends it to the servo.
more on the map(command[1], 32, 126, 2, 180) later...
the code here is expandable for whatever else you may need (eg. lights, motors, IR, etc.)

this code should work fine with no modifications.

Step 4: Install Software

I have two ways to install this...
nsis installer:
Download the self extracting installer below and run it.
You will have the option to install sources during the install.
the installer binary package installs core c++ dlls so it can be run on a computer without visual c++ installed already.
Once the installer finishes you can run it from the desktop or start menu.

zip way (unverified):
Download and run, it should work. maybe.
(The  zip archive has the same folder structure created by the installer, without sources. I don't have a machine without visual studio to test it on so it may not work.)

Step 5: Use the Interface Program

To use the program first select the baud rate defined in the arduino sketch.
The unmodified sketch defaults to 38400 baud but can be changed to suit your needs for things like a slower radio link. note: baud rates higher than 38400 have not been very stable, I think this is because the uart fills up before the data can be processed.
Next, select the COM port to use. the program defaults to COM4 be sure to change it or the program will crash.
Finally, click open. If all went well the program will open the selected serial port at selected baud rate.
If not the program will probably crash with an unhandled exception. make sure the port is correct and try again.
Use the textboxes to submit direct commands to the arduino. The "map(command[1], 32, 126, 2, 180)" scales all the 94 possible commands, *space* through ~, readable by the arduino in ASCII to 2 through 180 for the servo. any byte less than ASCII 32 (space) or above 126 (~) defaults to 63 (?)

The track bars provide an eaiser interface for direct commands. each step sends a serial command to the arduino incrementally.

Step 6: Get Creative!

Think of cool things to make with this. Some ideas:
1. Remote throttle for a car.
2. 3D camera mount
3. underwater rover

Have fun!!