Go Down

### Topic: Control 5 servos at the same time (external power supply) :0 (Read 295 times)previous topic - next topic

#### David_Pires

##### May 03, 2018, 06:11 pm
Hi I´m Dave I have 5 servos that I want to control I know that I will need an external power supply, but my problem is I want to control them at the same time.

I will have a potentiometer for each one of them and if I am rotating the potentiometer 1 and 2, motors 1 and 2 will both move. I don't know how is it possible hope u guys can help me.

#### vinceherman

#1
##### May 03, 2018, 06:15 pmLast Edit: May 03, 2018, 06:16 pm by vinceherman
5 servos and 5 pots.

Start out with 1 servo and 1 pot, as is done in this knob tutorial.

Then add a second pot and second servo.  It is easy to name the second instances with a 2 at the end of the name.  But you will quickly see that using arrays will be the right way to go.

Give it a try.  See how far you get.  Ask here if you have any questions.

#### David_Pires

#2
##### May 03, 2018, 06:21 pm
Ty for all I know how to do it for one or two the problem is move the servo one at the same time of the servo two.

#### vinceherman

#3
##### May 03, 2018, 08:01 pmLast Edit: May 03, 2018, 08:02 pm by vinceherman
This is how I would do it.
5 servo, 5 pot algorithm

declare and assign array of 5 servo pins
declare and assign array of 5 pot pins
declare array of 5 servos

in setup

loop through 5
attach each servos
set each pot pins as inputs

in loop

loop through 5
servo.write the mapped pot value

But seriously, start out with the knob tutorial.

#### slipstick

#4
##### May 03, 2018, 08:20 pm
Ty for all I know how to do it for one or two the problem is move the servo one at the same time of the servo two.
Just try it. It will do what you need. Take the delay() out.

It's not actually possible to do two things at EXACTLY the same time. The microprocessor only does one instruction followed by the next. But it's fast so it can do several things within a few microseconds of one another and unless you have a really unusual requirement that will be all you need.

Steve

Go Up