Moving two servos at once

I'm using an arduino 101 for an animatronic, and i seem to be having issues.

a small part of my code:

servoH.write(90); servoM.write(50); delay(500); servoM.write(90);

so whats happening is the mouth servo (indicated by servoM) opens and shuts the mouth on time until the head turn servo (servoH) is supossed to move. the servos move a little bit and then stop and then move a little bit after a two second delay; it repeats over and over until the servoH does not have to move anymore and they resume their tempo. ive tried 9v intead of 7.5 but it stilll happens. can the arduino move two servos at once at all?

The problem could be delay(500); That stops the micro dead in it's tracks until the delay has passed.

Don't use delay();

Time to study the "BlinkWithoutDelay" sketch in the examples of the IDE, to manage timings without using delay(). Leo..

can the arduino move two servos at once at all?

Yes but not with code written like that.

If you want two servos to move different amounts but arrive at the end point at the same time then you have to treat it like drawing a line on a display.

You have a different travel distance for each servo so you take the biggest and have that step towards the destination in steps of one. The smaller distance will be a fraction of this but you can’t step at a fractional rate. So what you have is an accumulator variable so that for every step of the furthest traveling servo you add your fractional increment to the accumulator variable. When this variable is over one you move the other servo one step and subtract one from the accumulator variable. This variable and the fraction increment variable both need to be of the float type.

You can use the delay function between each step to control the overall speed of the Motors.

Probably the most common problem with servos is insufficient power so make sure that whatever you are powering the system with can deliver enough current. It always worries me when someone says "9V" because they often mean those weedy little rectangular 9V batteries that can't provide enough current to drive even a single servo.

So what servos are you using (some need 5A or more on startup) and what exactly are you powering them with?


what exactly are you powering them with? Steve [/quote] a multi-voltage-wall-outlet-adapter-thing. also ill try to see blink without delay

a multi-voltage-wall-outlet-adapter-thing.

But the current capacity is the vital piece of information we need.

it can go from 3v to 12v

so looking at the Blink without Delay exercise i see that i will need to read the potentiometer at a certain interval and the use some If blocks of code for example the neck servo would read the potentiometer every 3 seconds (easy enough) but the hard part will be when i have to figure out how to make it check at different intervals

AtomicRustAG: it can go from 3v to 12v

Voltage is NOT current, that is measured in amps.

Try reading [url=http://][/url] for a view on what you have to do.

oh sorry i belive it is 800mA

You forgot to say WHAT SERVOS you are using. Some will be fine with 800mA. For other’s its nowhere near enough.