MeArm problem

I haven’t been using an arduino for a very long time and I have hooked it up to a MeArm robot. The program I have been using has been working really well, however, I have had a few problems:

When I first turn on the power the arm moves randomly and then starts moving as if half way through the program. The program then runs well over a few consecutive loops but then the MeArm starts to move violently and uncontrollably.

I also would like to know how to decrement movement using a for next loop.

I would be grateful of any help, I have linked my program below.

Thank you.

Grab4.ino.ino (1017 Bytes)

One of the difficulties with using ordinary servos is that they have no way to tell you their current position. Consequently, when you attach them in your code, they will move to their default position. Depending on how you left the robot arm after the last use, this may appear random.

Another possibility is that the arm is pulling too much current and reseting the arduino (assuming they share the same power supply). Put some serial.print statements in your setup routine to verify.

Looking at the arm, I'd expect that the left and right servos should always do the same thing - you seem to be moving them independently, which is probably putting the mechanicals under strain and causing more servo current draw, leading to a possible reset.

Note that "doing the same thing" likely doesn't mean setting them to the same angle. I expect you'll find that they'll need to be set to opposite angles. i.e. assuming a 180 degree travel, if one is set to 170, the other will need to be set to 10 (I'm guessing here though).