4 axis robot arm

#include <Servo.h>

Servo servo1;
Servo servo2;
Servo servo3; // create servo object to control a servo
Servo servo4;

int potpin1 = 0;  // analog pin used to connect the potentiometer
int potpin2 = 1;
int potpin3 = 2;
int potpin4 = 3;

int val;    // variable to read the value from the analog pin
int val2;
int val3;
int val4;

void setup() {
  servo1.attach(3);
  servo2.attach(5);
  servo3.attach(6);
  servo4.attach(9);// attaches the servo on pin 9 to the servo object
  
  
}

void loop() {
  val = analogRead(potpin1);            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  servo1.write(val);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there

  val2 = analogRead(potpin2);            // reads the value of the potentiometer (value between 0 and 1023)
  val2 = map(val2, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  servo2.write(val2);                  // sets the servo position according to the scaled value
  delay(15);        
  
  val3 = analogRead(potpin3);            // reads the value of the potentiometer (value between 0 and 1023)
  val3 = map(val3, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  servo3.write(val3);                  // sets the servo position according to the scaled value
  delay(15);    
  
  val4 = analogRead(potpin4);            // reads the value of the potentiometer (value between 0 and 1023)
  val4 = map(val4, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  servo4.write(val4);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there
}

So i'm making a 4 axis arm and i plugged one servo in to try it and it bugged out im using a HS-755HB servo

it bugged out im using a HS-755HB servo

What the heck does "it bugged out" mean?

How are you powering the servo?

Servo servo1;
Servo servo2;
Servo servo3; // create servo object to control a servo
Servo servo4;

int potpin1 = 0;  // analog pin used to connect the potentiometer
int potpin2 = 1;
int potpin3 = 2;
int potpin4 = 3;

int val;    // variable to read the value from the analog pin
int val2;
int val3;
int val4;

This just frosts me. If you are going to number variables in set, number ALL of them, as you do in the first two sets.

  servo1.attach(3);
  servo2.attach(5);
  servo3.attach(6);
  servo4.attach(9);// attaches the servo on pin 9 to the servo object

Servos do NOT need to be connected to PWM pins. They can be, but they do not NEED to be.

The servo spazzed out. I have a 6 volt batterey pack that goes to the breadboard and then a 9v goes to the Arduino. If I didn't connect to a PWM what does it get connected to?

I wired a servo to pin 3 and pot to A0 and ran your code. No bugging, operates smoothly. So the code is not the culprit.

You can connect the servo to a PWM pin, but you don't have to. Any I/O pin will do and you can connect up to 12 servos to an Uno.

can you show me your circuit setup? thanks

Do you have the 6V battery pack ground (- lead) tied to the Arduino and servo grounds? You should. Does your breadboard have a break in the upper and lower power rails. If so, is the break bridged?

And learn about arrays. They would make your code much shorter.

The servo spazzed out.

I find that expression very offensive term. You will get no help from me.

UKHeliBob:
I find that expression very offensive term. You will get no help from me.

k

I have a SSC-32U Lynx motion servo project extender could I somehow incorporate that to my device. (sorry I'm new to arduinos and robotics)

servo controller*

sciolyluvr:
I have a SSC-32U Lynx motion servo project extender could I somehow incorporate that to my device. (sorry I'm new to arduinos and robotics)

You could. But, why? The Arduino is perfectly capable of commanding servos with not servo controller needed.

PaulS:
You could. But, why? The Arduino is perfectly capable of commanding servos with not servo controller needed.

wouldn't you need a motor shield in order to control more then one servo?

When in doubt read the manual.

The Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega

You still need an external power supply capable of supplying enough current for the number of servos that are connected.