Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO Controlled Robotic Arm with PCA9685 PWM Servo Driver and Pushbutton Interaction

Image of Arduino UNO Controlled Robotic Arm with PCA9685 PWM Servo Driver and Pushbutton Interaction

Circuit Documentation

Summary

This circuit is designed to control multiple servo motors using an Arduino UNO microcontroller and an Adafruit PCA9685 PWM Servo Breakout board. The circuit includes input devices such as rotary potentiometers and a pushbutton to provide interactive control. Additionally, the circuit features LEDs for visual feedback and a rocker switch for power management. The Arduino UNO is programmed to read the potentiometer values and control the position of the servos accordingly. The pushbutton is used to control the opening and closing of a gripper servo.

Component List

  • Arduino UNO: A microcontroller board based on the ATmega328P, with a variety of digital and analog I/O pins.
  • Adafruit PCA9685 PWM Servo Breakout: A 16-channel, 12-bit PWM controller for servo motors, with an I2C interface.
  • Servo Motors: Actuators that can be precisely controlled for position, commonly used for robotics and RC vehicles.
  • LEDs (Green): Light-emitting diodes that provide visual feedback, typically used as indicators.
  • Rocker Switch: A switch used to connect or disconnect the circuit from power.
  • 2.1mm Barrel Jack with Terminal Block: A connector for power supply input.
  • Rotary Potentiometers: Variable resistors that provide a variable voltage output, used as analog inputs to the microcontroller.
  • Pushbutton: A momentary switch that provides a digital input to the microcontroller.

Wiring Details

Arduino UNO

  • 3.3V to LED (Green) anode
  • 5V to Adafruit PCA9685 PWM Servo Breakout VCC
  • GND to LED (Green) cathode, Adafruit PCA9685 PWM Servo Breakout GND
  • Vin to Adafruit PCA9685 PWM Servo Breakout 5.0V
  • A0 - A3 to Rotary Potentiometers leg2
  • SCL to Adafruit PCA9685 PWM Servo Breakout SCL
  • SDA to Adafruit PCA9685 PWM Servo Breakout SDA
  • D13 to Pushbutton Pin 4 (out)

Adafruit PCA9685 PWM Servo Breakout

  • 5.0V to Servo Motors vcc
  • GND to Servo Motors gnd, 2.1mm Barrel Jack with Terminal Block POS, Rotary Potentiometers wiper
  • PWRIN to Rocker Switch 1
  • PWM7 - PWM15 to Servo Motors pulse

Servo Motors

  • gnd to Adafruit PCA9685 PWM Servo Breakout GND
  • vcc to Adafruit PCA9685 PWM Servo Breakout 5.0V
  • pulse to Adafruit PCA9685 PWM Servo Breakout PWM7 - PWM15

LEDs (Green)

  • cathode to Arduino UNO GND
  • anode to Arduino UNO 3.3V

Rocker Switch

  • 1 to Adafruit PCA9685 PWM Servo Breakout PWRIN
  • 2 to 2.1mm Barrel Jack with Terminal Block NEG

2.1mm Barrel Jack with Terminal Block

  • POS to Adafruit PCA9685 PWM Servo Breakout GND
  • NEG to Rocker Switch 2

Rotary Potentiometers

  • leg1 to Adafruit PCA9685 PWM Servo Breakout VCC
  • wiper to Arduino UNO A0 - A3, Pushbutton Pin 1 (in)
  • leg2 to Arduino UNO A0 - A3

Pushbutton

  • Pin 3 (out) to Arduino UNO D13
  • Pin 4 (out) to Arduino UNO D13
  • Pin 1 (in) to Rotary Potentiometers wiper
  • Pin 2 (in) to Rotary Potentiometers wiper

Documented Code

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

#define MIN_PULSE_WIDTH       650
#define MAX_PULSE_WIDTH       2350
#define FREQUENCY             50

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

int potWrist = A3;
int potElbow = A2;
int potShoulder = A1;
int potBase = A0;

int hand = 11;
int wrist = 12;
int elbow = 13;
int shoulder = 14;
int base = 15;

void setup() 
{
  delay(5000); // Delay for controller to reach starting position
  pwm.begin();
  pwm.setPWMFreq(FREQUENCY);
  pwm.setPWM(11, 0, 90); // Set Gripper to 90 degrees (Close Gripper)
  pinMode(13, INPUT_PULLUP);
  Serial.begin(9600);
}

void moveMotor(int controlIn, int motorOut)
{
  int pulse_wide, pulse_width, potVal;
  potVal = analogRead(controlIn); // Read value of Potentiometer
  pulse_wide = map(potVal, 800, 240, MIN_PULSE_WIDTH, MAX_PULSE_WIDTH);
  pulse_width = int(float(pulse_wide) / 1000000 * FREQUENCY * 4096); // Map Potentiometer to Motor
  pwm.setPWM(motorOut, 0, pulse_width);
}

void loop() 
{
  moveMotor(potWrist, wrist);
  moveMotor(potElbow, elbow);
  moveMotor(potShoulder, shoulder);
  moveMotor(potBase, base);

  int pushButton = digitalRead(13);
  if(pushButton == LOW)
  {
    pwm.setPWM(hand, 0, 180); // Keep Gripper closed when button not pressed
    Serial.println("Grab");
  }
  else
  {
    pwm.setPWM(hand, 0, 90); // Open Gripper when button pressed
    Serial.println("Release");
  }
}

This code is designed to run on the Arduino UNO microcontroller. It initializes the Adafruit PCA9685 PWM Servo Driver and sets up the servo motors to their initial positions. The moveMotor function reads the analog values from the potentiometers and maps them to the servo pulse width, controlling the position of the servos. The pushbutton is used to toggle the gripper servo between open and closed positions.