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

Arduino-Based Bluetooth-Controlled Servo System with Flex Sensors and MPU-6050

View and Edit Project In Cirkit DesignerImage of Arduino-Based Bluetooth-Controlled Servo System with Flex Sensors and MPU-6050

Circuit Documentation

Summary

This circuit involves an Arduino UNO and an Arduino Nano, which are used to control multiple servos and read sensor data. The servos are controlled via a PCA9685 PWM driver, and the sensor data is read from flex sensors and an MPU-6050 accelerometer. The data is communicated between the Arduino Nano and Arduino UNO using Bluetooth modules.

Component List

Micro Servo 9G

Arduino UNO

Adafruit PCA9685 PWM Servo Breakout

Arduino Nano

HC-05 Bluetooth Module

2.2 inch Basic Flex Resistor

Resistor

MPU-6050

Wiring Details

Micro Servo 9G

Arduino UNO

Adafruit PCA9685 PWM Servo Breakout

Arduino Nano

HC-05 Bluetooth Module

2.2 inch Basic Flex Resistor

Resistor

MPU-6050

Code Documentation

Arduino UNO Sketch

/*
 * Arduino UNO Sketch
 * This code controls three servos connected via a PCA9685 PWM driver.
 * The servos are connected to PWM channels 0, 4, and 8 of the PCA9685.
 * The servos will move slowly back and forth.
 */

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

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

const int servoMin = 150; // Minimum pulse length count (out of 4096)
const int servoMax = 600; // Maximum pulse length count (out of 4096)

void setup() {
  pwm.begin();
  pwm.setPWMFreq(60); // Analog servos run at ~60 Hz updates
}

void loop() {
  for (uint16_t pulselen = servoMin; pulselen < servoMax; pulselen++) {
    pwm.setPWM(0, 0, pulselen);
    pwm.setPWM(4, 0, pulselen);
    pwm.setPWM(8, 0, pulselen);
    delay(10);
  }
  for (uint16_t pulselen = servoMax; pulselen > servoMin; pulselen--) {
    pwm.setPWM(0, 0, pulselen);
    pwm.setPWM(4, 0, pulselen);
    pwm.setPWM(8, 0, pulselen);
    delay(10);
  }
}

Arduino Nano Sketch

/*
 * Arduino Nano Sketch
 * This code reads values from two flex sensors and an MPU-6050 accelerometer
 * and sends the data to an Arduino UNO via Serial communication.
 * The flex sensors are connected to analog pins A6 and A7.
 * The MPU-6050 is connected via I2C to pins A4 (SDA) and A5 (SCL).
 * The data is sent over a Bluetooth module