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

Arduino UNO Controlled Robotic Arm with Multiple Servos and Pushbutton Control

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled Robotic Arm with Multiple Servos and Pushbutton Control

Circuit Documentation

Summary

This circuit involves an Arduino UNO microcontroller, multiple pushbuttons, and servos. The Arduino UNO is used to control the servos based on the input from the pushbuttons. The servos are connected to the Arduino UNO and are powered through it. The pushbuttons are used to provide input signals to the Arduino, which then processes these signals to control the servos.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. Servo (3 units)

    • Description: A motor that can be controlled to move to a specific position.
    • Pins: gnd, vcc, pulse
  3. Pushbutton (6 units)

    • Description: A simple switch mechanism for controlling some aspect of a machine or a process.
    • Pins: Pin 3 (out), Pin 4 (out), Pin 1 (in), Pin 2 (in)

Wiring Details

Arduino UNO

Servo 1

Servo 2

Servo 3

Pushbutton 1

Pushbutton 2

Pushbutton 3

Pushbutton 4

Pushbutton 5

Pushbutton 6

Code Documentation

#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;                        // Assign Potentiometers to pins on Arduino Uno
int potShoulder = A1;
int potBase = A0;

int hand = 11;
int wrist = 12;
int elbow = 13;                           // Assign Motors to pins on Servo Driver Board
int shoulder = 14;
int base = 15;

void setup() 
{
  delay(5000);                            // <-- So I have time to get controller to 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 position to Motor
  
  pwm.setPWM(motorOut, 0, pulse_width);
}

void loop() 
{
  moveMotor(potWrist, wrist);
  moveMotor(potElbow, elbow);                                                       // Assign Motors to corresponding Potentiometers
  moveMotor(potShoulder, shoulder);
  moveMotor(potBase, base);

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

This code initializes the PWM servo driver and sets up the pins for the potentiometers and servos. The moveMotor function maps the potentiometer values to the servo positions. The loop function continuously reads the potentiometer values and updates the servo positions accordingly. Additionally, it reads the state of a pushbutton to control the gripper servo.