Programming Servos

Hi,
I'm new to Arduino's and was wondering if I could have some help.

I've got an Arduino uno and the basic MeArm. I'm trying to get the servos to turn, but can't figure out the right code.

So far, this is what I've got:

#include <Servo.h>
Servo middle, left, right, claw;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
middle.attach(11);
left.attach(10);
right.attach(9);
claw.attach(6);
}

void loop() {
// put your main code here, to run repeatedly:
middle.write(90);
left.write(90);
right.write(90);
claw.write(35);
delay(10);
}

Should I be getting any actual movement from this code, or do I need to add in extra? If so, What..?

Thanks

Should I be getting any actual movement from this code

No. The servos should move to their commanded (fixed) positions and stay there.

Try the Sweep example with one servo. Does it work ?

How are the servos powered ?
Do not use the 5V and GND connections of the Arduino as it can only supply limited current and you may have already damaged it.

Hi,
Thanks

I've just tried the sweep example, and have got one servo going. (had to use the 5v and GND connection though). How do I get the power through all of the other servos? and control their movements?
(I've got a breadboard if that helps!)

The servos are currently powered through 6AA batteries linked through the external power supply port.
How should I be sending the current through to the servos without using the 5V and GND connections?

The sweep example works by sending a series of different position commands to the servo whereas your original program sent the same position command over and over again.

The servos probably need 5V so 6 AAs is too high to power them directly. What you need to do is to connect the servo power leads to + and GND of a 5V supply (or thereabouts) 4 AAs will do. Can you tap that off your 6AA pack ? Connect the power GND and Arduino GND together and connect the servo control wire to your chosen Arduino output pin. The servo will be running on the external power supply and the Arduino can continue to run on the 6AA pack as now. The signal wire and common GND allow the Arduino and servo to communicate.

Come back when you have got that working and have perhaps tried the Servo Knob example

Power the servos with just 4 batteries, ~6V.
Connect the battery- to the Arduino Gnd.
Connect the servo control signal lines to the Arduino control pins.

Like IKHeliBob said :wink: