Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Uno Controlled 6-Servo Robot Arm with 3 Analog Joysticks

View and Edit Project In Cirkit DesignerImage of Arduino Uno Controlled 6-Servo Robot Arm with 3 Analog Joysticks

Circuit Documentation

Summary

This circuit is designed to control a robot arm with 6 servos using 3 analog joysticks. The system is powered by a 5V 5A power supply and is controlled by an Arduino Uno R3 microcontroller. Each joystick controls two servos: one for the vertical axis and one for the horizontal axis.

Component List

  1. Arduino Uno R3

    • Description: Microcontroller board based on the ATmega328P.
    • Pins: D8, D9, D10, D11, D12, D13, GND, AREF, SDA, SCL, D0/RX, D1/Tx, D2, D3, D4, D5, 6, D7, A5/SCL, A4/SDA, A3, A2, A1, A0, Vin, 5V, 3.3V, RESET, IOREF, NONE, USB Jack, Power Jack.
  2. MG996R Servo Motor

    • Description: High-torque digital servo motor.
    • Pins: GND, VCC, SIG.
  3. Analog Joystick

    • Description: Analog joystick module with two potentiometers and a push button.
    • Pins: VCC, VERT, HORZ, SEL, GND.
  4. POWER SUPPLY 5V 5AMP

    • Description: Power supply providing 5V DC at 5A.
    • Pins: 220V Positive Pole (AC), 220V Negative Pole (AC), GND, GND (DC), 12V-24V Output (DC).

Wiring Details

Arduino Uno R3

MG996R Servo Motors

Analog Joysticks

POWER SUPPLY 5V 5AMP

Code Documentation

/*
 * Robot Arm with 6 Servos and 3 Joysticks
 *
 * This code controls a robot arm with 6 servos using 3 analog joysticks.
 * Each joystick controls two servos: one for the vertical axis and one for
 * the horizontal axis.
 */

#include <Servo.h>

// Define servo objects
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
Servo servo6;

// Define joystick pins
const int joy1Vert = A0;
const int joy1Horz = A1;
const int joy2Vert = A2;
const int joy2Horz = A3;
const int joy3Vert = A4;
const int joy3Horz = A5;

// Define servo pins
const int servo1Pin = 2;
const int servo2Pin = 3;
const int servo3Pin = 4;
const int servo4Pin = 5;
const int servo5Pin = 6;
const int servo6Pin = 7;

void setup() {
  // Attach servos to pins
  servo1.attach(servo1Pin);
  servo2.attach(servo2Pin);
  servo3.attach(servo3Pin);
  servo4.attach(servo4Pin);
  servo5.attach(servo5Pin);
  servo6.attach(servo6Pin);
}

void loop() {
  // Read joystick values
  int joy1VertVal = analogRead(joy1Vert);
  int joy1HorzVal = analogRead(joy1Horz);
  int joy2VertVal = analogRead(joy2Vert);
  int joy2HorzVal = analogRead(joy2Horz);
  int joy3VertVal = analogRead(joy3Vert);
  int joy3HorzVal = analogRead(joy3Horz);

  // Map joystick values to servo angles
  int servo1Angle = map(joy1VertVal, 0, 1023, 0, 180);
  int servo2Angle = map(joy1HorzVal, 0, 1023, 0, 180);
  int servo3Angle = map(joy2VertVal, 0, 1023, 0, 180);
  int servo4Angle = map(joy2HorzVal, 0, 1023, 0, 180);
  int servo5Angle = map(joy3VertVal, 0, 1023, 0, 180);
  int servo6Angle = map(joy3HorzVal, 0, 1023, 0, 180);

  // Write angles to servos
  servo1.write(servo1Angle);
  servo2.write(servo2Angle);
  servo3.write(servo3Angle);
  servo4.write(servo4Angle);
  servo5.write(servo5Angle);
  servo6.write(servo6Angle);

  // Small delay to allow servos to move
  delay(15);
}

This code initializes six servo objects and assigns them to specific pins on the Arduino Uno R3. It reads the analog values from the three joysticks and maps these values to servo angles, which are then written to the servos to control their positions. The loop continuously updates the servo positions based on the joystick inputs.