How to program arduino arm

Hello,

We are trying to program an Arduino arm but are having trouble getting it to move properly.The main focus is to have each section of the arm move independently and in a sequence using servo motors.

Here is a photo of the arm:

shorturl.at/cR028

We would like each part of it to move up and down a certain angle value.

Here is the code we have written for the two bottom motors:

#include <Servo.h>

Servo servo2;
Servo servo1;
Servo servo15;
int pos1=0;
int pos2=0;
int pos15=0;

void setup(){
servo1.attach(4);
servo2.attach(5);
servo15.attach(3);

}

void loop(){
for(pos1=0;pos1<=20;pos1+=20)
servo1.write(pos1);
for(pos2=0; pos2<=-20; pos2+=20)
servo2.write(pos2);
delay(1000);
for(pos15 =0; pos15<= 110; pos15 +=110)
servo15.write(pos15);
delay(1000);
for(pos15=0; pos15>=45; pos15 -= 45)
servo15.write(pos15);
delay(1000);
for(pos1=0;pos1>=40; pos1-=-40)
servo1.write(pos1);
for(pos1=0; pos1>= 40; pos1 -=40)
servo1.write(pos1);
delay(1000);
}

When we run it, the servos would go to 90 degrees. If the arm was pushed up, it did go to 20 degrees, but only when pushed. It did not move from 20 degrees to zero degrees at all.

for(pos2=0; pos2<=-20; pos2+=20)
  servo2.write(pos2);

?

"shorturl.at/cR028"

That doesn't seem to wok for an image.

for(pos15=0; pos15>=45; pos15 -= 45)

If you start at 0 how long do you think it will be great than 45, particularly if you subtract 45 from the 0?

But anyway if you just want your servos to go direct to specific positions you don't need to mess with for loops. Just do write(position).

Steve

Hello,

Thanks for your response. We have attempted to control it using the write(position) method, but the servo only runs the program when someone nudges it in that direction. Either we nudge it, or it does not move at all.

Then you are not providing enough power to the servos. Either the battery/power supply is too weak (e.g you are trying to power the servos from the Arduino 5V pin) or the wiring/connectors are bad, perhaps wires too thin or connecting servos through a breadboard etc.

Please post a picture showing all connections and wiring and provide details what servos you use and how everything is powered.

Steve