How to control 2 servos simultaneously with both having independent output?

Hi everyone,

I had 2 servos, arduino mega 2560 and motor driver SC08A.

I connected the 2 servos on the servo ports provided on the motor driver, then i connect the motor driver to arduino mega.

Is there any program that allow me to manipulate both servos independently but simultaneously with this hardware configuration?

Thank you everyone ^^

*I had attached the pic of my hardware configuration.

If you can control one, you can control many. Add it all in the loop() and control accordingly.

mistergreen:
If you can control one, you can control many. Add it all in the loop() and control accordingly.

I'm new in arduino and coding. Mind showing me the example coding that suits this hardware configuration? Thank you ^^

Why are you using a servo driver?- the Arduino servo library can control servos adequately, and it's easy just to "double up" so to speak, by adapting code like the sweep example.

Where it currently has this....

Servo myservo;

void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
}

.... you just do this say:

Servo myservo;
Servo myservo2;

void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
  myservo2.attach(10);  // attaches the servo on pin 10 to the servo object 
}

Then further down in the code you just use myservo2 like they currently use myservo.

Or am I missing something?

JimboZA:
Why are you using a servo driver?- the Arduino servo library can control servos adequately, and it's easy just to "double up" so to speak, by adapting code like the sweep example.

Where it currently has this....

Servo myservo;

void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}




.... you just do this say:



Servo myservo;
Servo myservo2;

void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
  myservo2.attach(10);  // attaches the servo on pin 10 to the servo object
}




Then further down in the code you just use myservo2 like they currently use myservo.

Or am I missing something?

Yup I know the arduino board can handle a number of servos. I just wandering how to define each servos connected to the motor driver in the coding.

Normally for servos that are connected directly to the arduino board, the servos can be define individually base on the output pin number from the arduino board.

But now i had all the servos connected to SC08A motor driver and the RX of the driver is connected to TX1 of Arduino Mega 2560. I don’t know how to define each servos now because i only used Pin TX1 on the arduino.

Need help thank you everyone.

That's essentially the same question you asked here....

JimboZA:
That's essentially the same question you asked here....

yeah I still cant figure it out T.T

Threads merged. @JoonSeng91, do not cross-post.

Have you consulted the documentation of the servo driver board?

Why are you using it: what advantage do you expect to gain from adding an extra layer of complexity?

JimboZA:
Have you consulted the documentation of the servo driver board?

Why are you using it: what advantage do you expect to gain from adding an extra layer of complexity?

simplify the board coz with motor driver thr will be less wires.

motor driver thr will be less wires.

Whilst it is true that there will be fewer (sic) wires between the Arduino and the driver board that is true, but each servo requires 3 wires whether a servo driver board is used or not. If you add in the serial connection there will be more wires when using the driver board.

In actual fact, if the servo power supply is local to the servos only one wire is needed for each servo between the Arduino and each servo plus one common GND wire.

UKHeliBob:
Whilst it is true that there will be fewer (sic) wires between the Arduino and the driver board that is true, but each servo requires 3 wires whether a servo driver board is used or not. If you add in the serial connection there will be more wires when using the driver board.

In actual fact, if the servo power supply is local to the servos only one wire is needed for each servo between the Arduino and each servo plus one common GND wire.

Yeah its true. But let's say if the usage of the motor driver is mandatory and thr's only 3 wires connected between the Arduino and the motor driver(5V, GRD, TX1<>RX), how should i write the coding to define each servos connected because only the TX1 pin on the Arduino is used.

We don't know how to program your board. It clearly needs some stuff sent from Arduino serial to it, and the only way you'll figure out what that is, is to consult that board's docs and see what it expects.

Once you know that, then you can get help here with (say) how to construct strings of stuff to send from the Arduino, but you need to figure out WHAT to send, first.

If the use of that board isn't compulsory, I'd say you should chuck it out.

how should i write the coding to define each servos connected

Post a link to the motor driver board.