Robotic Arm with Servos assistance

Hey everyone, I'm currently making a robotic arm using servos and rotational sensors. The Arm is composed of 4 micro SG90 servos and each is controlled by a B10K rotational sensor. The parts for the robotic arm are all 3D printed and they all are attached just fine.

My main concern is when i do run the code, the servo sometimes doesn't even respond when i try to turn the B10K. Usually it then turns after 2-3 seconds after. As well, the movement itself isn't that smooth and it sometimes just jitters back and forth. If any of you could please help me make it so that it is more smooth, that will be appreciated. Thanks! (PS, im only using two sensors and servos for now just to test. I will add the other two later)

The code:

#include <Servo.h>

Servo servo1;
Servo servo2;

int servoPin1 = 9;
int rotationPin1 = A0;

int servoPin2 = 10;
int rotationPin2 = A1;

void setup() {
  servo1.attach(servoPin1);
  servo2.attach(servoPin2);

}

void loop() {
    int read1 = analogRead(rotationPin1);
    int angle1 = map(read1, 0, 1023, 0, 180);
    servo1.write(angle1);

    int read2 = analogRead(rotationPin2);
    int angle2 = map(read2, 0, 1023, 0, 180);
    servo2.write(angle2);

}
  • Schematic diagrams are the universal language of electronics.
  • We use schematics to communicate hardware design. All components and connections are illustrated.
  • As always, show us a good schematic of your proposed circuit. Hand drawn schematics are acceptable.
  • Show us several good image views of your actual wiring.

It is a bit messy and un organized, but if you have any questions about what connects with what, let me know.

Here is a picture of my arm below:

  • Please confirm those are potentiometers and not rotary encoders.
    What is their resistance ?
  • Never power servos from the Arduino 5v pin, use an external power supply/battery.

it says online that the resistance is 10,000 ohms, It is a potentiometer by the way.

Also how can i attach a battery for power and also upload the code?

5v power supplies available on Amazon

Use AA batteries

Thanks, but is there anything i can do with the code to make it move smoother?

  • Does the circuit work with one servo only (disconnected the 2nd) ?

no so both servos turn, the problem is that the movement itself is jittery and rough

  • The first thing you need to do is power the servos externally.

  • Your sketch works here as expected when using an external 5V servo power supply.

  • Print the angle values to the serial monitor to confirm they are not fluctuating.

void setup() 
{
  Serial.begin(115200);    //make sure you set the serial monitor to the same rate <——<<<<

  servo1.attach(servoPin1);
  servo2.attach(servoPin2);

}

void loop() 
{
    int read1 = analogRead(rotationPin1);
    int angle1 = map(read1, 0, 1023, 0, 180);

    Serial.print(“angle1 = “);
    Serial.println(angle1);

    servo1.write(angle1);

    int read2 = analogRead(rotationPin2);
    int angle2 = map(read2, 0, 1023, 0, 180);

    Serial.print(“angle2 = “);
    Serial.println(angle2);

    servo2.write(angle2);

    //for testing, slow things down a bit
    delay(500); 
}

I have powered it with a 9V battery and both angles are showing in the serial monitor as I move the potentiometers. It still is a bit jittery in a certain spot and just moves back and forth rapidly.

  • Hobby servos need 5 to 6 volts, anything more will damage the servo.

  • Use 4 AA batteries, negative goes to Arduino GND (0v)