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

Arduino and PCA9685 Controlled Robotic Hand with Flex Sensors

View and Edit Project In Cirkit DesignerImage of Arduino and PCA9685 Controlled Robotic Hand with Flex Sensors

Circuit Documentation

Summary

This circuit involves an Arduino UNO, an Arduino Nano, an Adafruit PCA9685 PWM Servo Breakout, multiple resistors, flex resistors, and micro servos. The circuit is designed to control the movement of servos based on input from flex resistors, with communication facilitated by Bluetooth.

Component List

  1. Micro servo 9G

    • Pins: GND, +5V, PWM
    • Description: A small servo motor used for precise control of angular position.
  2. Arduino UNO

    • 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
    • Description: A microcontroller board based on the ATmega328P.
  3. Adafruit PCA9685 PWM Servo Breakout

    • Pins: 5.0V, GND, PWRIN, PWM7, PWM6, PWM5, PWM4, PWM3, PWM2, PWM1, PWM0, VCC, SDA, SCL, OE, PWM15, PWM14, PWM13, PWM12, PWM11, PWM10, PWM9, PWM8
    • Description: A 16-channel PWM driver for controlling servos.
  4. 2.2 inch Basic Flex Resistor

    • Pins: Pin 2, pin 1
    • Description: A flexible resistor that changes resistance when bent.
  5. Resistor

    • Pins: pin1, pin2
    • Description: A passive electrical component that provides resistance.
    • Properties: Resistance: 10 Ohms
  6. Arduino Nano

    • Pins: D1/TX, D0/RX, RESET, GND, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11/MOSI, D12/MISO, VIN, 5V, A7, A6, A5, A4, A3, A2, A1, A0, AREF, 3V3, D13/SCK
    • Description: A small, complete, and breadboard-friendly board based on the ATmega328P.

Wiring Details

Micro servo 9G

Micro servo 9G

Arduino UNO

Adafruit PCA9685 PWM Servo Breakout

2.2 inch Basic Flex Resistor

Resistor

Arduino Nano

Code Documentation

Arduino UNO Code

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

// Define pins
const int bluetoothRxPin = 11; // RX pin for Bluetooth module
const int bluetoothTxPin = 10; // TX pin for Bluetooth module

// Create PWM driver instance
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

// Define servo channels on the PCA9685
const int servo1Channel = 4;
const int servo2Channel = 8;

// Define servo positions
const int openPosition = 150;
const int closePosition = 600; 

void setup() {
  Serial.begin(9600); // Initialize serial communication
  pinMode(bluetoothRxPin, INPUT);
  pinMode(bluetoothTxPin, OUTPUT);
  pwm.begin();
  pwm.setPWMFreq(60); // Analog servos run at ~60 Hz
}

void loop() {
  if (Serial.available() > 0) {
    String command = Serial.readStringUntil('\n');
    if (command == "Grip Close") {
      pwm.setPWM(servo1Channel, 0, closePosition);
      pwm.setPWM(servo2Channel, 0, closePosition);
    } else if (command == "Grip Open") {
      pwm.setPWM(servo1Channel, 0, openPosition);
      pwm.setPWM(servo2Channel, 0, openPosition);
    }
  }
  delay(100); // Small delay to avoid spamming
}

Adafruit PCA9685 PWM Servo Breakout Code

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

Arduino Nano Code

const int flexSensor1Pin = A6;
const int flexSensor2Pin = A7;
const int bluetoothTxPin = 2;
const int bluetoothRxPin = 3;

void setup() {
  Serial.begin(9600); // Initialize serial communication
  pinMode(flexSensor1Pin, INPUT);
  pinMode(flexSensor2Pin, INPUT);
  pinMode(bluetoothTxPin, OUTPUT);
  pinMode(bluetoothRxPin, INPUT);
}

void loop() {
  int flexValue1 = analogRead(flexSensor1Pin);
  int flexValue2 = analogRead(flexSensor2Pin);

  if (flexValue1 < 380 || flexValue2 < 230) {
    Serial.println("Grip Close");
    // Send signal to close the grip
    digitalWrite(bluetoothTxPin, HIGH);
  } else if (flexValue1 > 410 || flexValue2 > 260){
    Serial.println("Grip Open");
    // Send signal to open the grip
    digitalWrite(bluetoothTxPin, LOW);
  }

  delay(100); // Small delay to avoid spamming
}