File Exchange

image thumbnail

Servo motors controller

version (9.88 KB) by Andrea Cirillo
A GUI to control six servo motors.


Updated 03 Jan 2011

View License

It's a servo controller for six servo motors. It can be used to control a antropomorphic arm with six motors. For a correct execution, it must select the motors following this table:
#servo - char to use for the motor selection
1 a
2 b
3 c
4 d
5 e
6 f
The microcontroller must use the same char. It uses a serial communication via RS232 protocol.

Comments and Ratings (12)

Hi! The problem is, how to move the servo according to the byte sent? I mean, how to setup the PWM vs MCU clock and make a source code in order to obtain a servo movement same as the slide bar value (1 degree precision). Anyone could help me please?

pooja sheth

nice work

Hi Andrea,
Thank you for the great effort. I tried your matlab code and the simple fix for the Arduino from last comments and still having problems.
Your Additional support would be most appreciated. Keeping in mind I'm using the Arduino UNO board / USB serial port. Could that be the problem? Do you have code for the USB port? Thank you

Hi Harris,
I think that a simple Arduino solution like the following one should be work fine! Let me know if you need for further help.

int incomingByte = 0; // for incoming serial data
char selectedMotor;

void setup() {

void loop() {
if (Serial.available() > 0) {
// read the incoming byte:
selectedMotor =;
incomingByte =;

if (selectedMotor == 'a') {
// active first motor
else if (selectedMotor == 'b') {
// active second motor
/* And so on... */

Harris Ko

The gui is similar to what i would like to use. The problem i have is what code to write for the arduino. Could you please post a sample of code for the arduino?( i am new to arduino and matlab interaction)

gracias por esta ayuda es de mucha utilidad


Thanks, for this good serial port code.

Yes. It is a very simple algorithm.


is it like this:

PIC microcontroller:
if motorSelection == a
then activate motor1
else if motorSelection == b
then activate motor2
else if motorSelection == f
then activate motor6?


The software needs a simple circuit microcontroller based.


how will this work? SERVO to PC? no need for microcontroller?



MATLAB Release Compatibility
Created with R2010b
Compatible with any release
Platform Compatibility
Windows macOS Linux