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

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

View and Edit Project In Cirkit DesignerImage 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

Wiring Details

Arduino UNO

Adafruit PCA9685 PWM Servo Breakout

Servo Motors

LEDs (Green)

Rocker Switch

2.1mm Barrel Jack with Terminal Block

Rotary Potentiometers

Pushbutton

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.