Gesture-Controlled Wheelchair with Arduino UNO, Arduino Nano, and HC-05 Bluetooth Modules
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
The circuit in question is a complex system designed to interface an Arduino UNO, an Arduino Nano, an HC-05 Bluetooth module, an InvenSense MPU6050 accelerometer/gyroscope, an L298N DC motor driver, two DC motors, and a couple of battery power sources. The Arduino UNO is the primary microcontroller, while the Arduino Nano serves as a secondary controller interfacing with the MPU6050 and an additional HC-05 Bluetooth module. The L298N motor driver controls the two DC motors, and the system is powered by a 4 x AAA battery mount and a separate battery case.
Component List
Arduino UNO
- Microcontroller board based on the ATmega328P
- Features digital I/O pins, analog input pins, and various power outputs
Arduino Nano
- Compact microcontroller board based on the ATmega328
- Includes digital I/O pins, analog inputs, and dedicated SPI/I2C pins
HC-05 Bluetooth Module (x2)
- Bluetooth to serial port module, used for wireless communication
- Features RX/TX pins for serial communication and a State pin for connection status
InvenSense MPU6050
- Motion tracking device with a 3-axis accelerometer and a 3-axis gyroscope
- Communicates via I2C protocol
L298N DC Motor Driver
- Dual H-bridge motor driver capable of driving two DC motors
- Provides pins for motor outputs, power supply, and control inputs
DC Motor (x2)
- Electric motors powered by direct current (DC)
- Each motor has two pins for power connection
4 x AAA Battery Mount
- Power source for the circuit
- Provides a positive and negative terminal for power distribution
My Battery Case
- An additional power source
- Includes positive and negative terminals
Wiring Details
Arduino UNO
5VandGNDconnected to the HC-05 Bluetooth Module for powerVinconnected to the L298N DC motor driver's5Vfor power- Digital pins
D8,D7,D4, andD2connected toIN4,IN3,IN2, andIN1on the L298N motor driver for motor control D1andD0connected toRXDandTXDon the HC-05 Bluetooth Module for serial communication
Arduino Nano
3V3connected to the MPU6050'sVCCand the HC-05 Bluetooth Module'sStateA4andA5connected to the MPU6050'sSDAandSCLfor I2C communication5Vconnected to the HC-05 Bluetooth Module'sVCCfor powerGNDconnected to the MPU6050'sGND, the HC-05 Bluetooth Module'sGND, andMy battery case's-for common groundD0/RXandD1/TXconnected to the HC-05 Bluetooth Module'sTXDandRXDfor serial communicationVINconnected toMy battery case's+for power
HC-05 Bluetooth Module
- One module connected to the Arduino UNO for serial communication and power
- Another module connected to the Arduino Nano for serial communication and power
InvenSense MPU6050
VCCandGNDconnected to the Arduino Nano for powerSDAandSCLconnected to the Arduino Nano for I2C communication
L298N DC Motor Driver
OUT1,OUT2,OUT3, andOUT4connected to the DC Motors for motor output12Vconnected to the 4 x AAA Battery Mount's+for powerGNDconnected to the 4 x AAA Battery Mount's-for common groundIN1,IN2,IN3, andIN4connected to the Arduino UNO for control signals
DC Motors
- Each motor connected to the L298N DC motor driver's corresponding output pins
4 x AAA Battery Mount
+connected to the L298N DC motor driver's12Vfor motor power-connected to the L298N DC motor driver'sGNDfor common ground
My Battery Case
+connected to the Arduino Nano'sVINfor power-connected to the Arduino Nano'sGNDfor common ground
Documented Code
Arduino UNO Code
#include <Adafruit_MPU6050.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
int x, y;
Adafruit_MPU6050 mpu;
void setup(void) {
Serial.begin(115200);
while (!Serial)
delay(10);
Serial.println("Adafruit MPU6050 test!");
// Try to initialize!
if (!mpu.begin()) {
Serial.println("Failed to find MPU6050 chip");
while (1) {
delay(10);
}
}
Serial.println("MPU6050 Found!");
mpu.setAccelerometerRange(MPU6050_RANGE_8_G);
mpu.setGyroRange(MPU6050_RANGE_500_DEG);
mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);
Serial.println("");
delay(100);
}
void loop() {
sensors_event_t a, g, temp;
mpu.getEvent(&a, &g, &temp);
x = a.acceleration.x;
y = a.acceleration.y;
Serial.print("Acceleration X: ");
Serial.print(a.acceleration.x);
Serial.print(", Y: ");
Serial.print(a.acceleration.y);
Serial.print(", Z: ");
Serial.print(a.acceleration.z);
Serial.println(" m/s^2");
// Rear motors control (forward and reverse)
if (y >= 4) {
Serial.println("Forward");
Serial.write("F"); // Command to move forward
} else if (y <= -4) {
Serial.println("Backward");
Serial.write("B"); // Command to move backward
} else {
Serial.println("Stop");
Serial.write("S"); // Command to stop
}
// Front motors control (left and right)
if (x >= 4) {
Serial.println("Left");
Serial.write("L"); // Command to turn left
} else if (x <= -4) {
Serial.println("Right");
Serial.write("R"); // Command to turn right
}
}
Arduino Nano Code (HC-05 Bluetooth Module)
/*
* Arduino Sketch for Gesture Control Wheelchair
*
* This code interfaces with an HC-05 Bluetooth module to receive commands
* and sends them to the main Arduino UNO microcontroller to control the
* wheelchair's movement.
*/
// Pin definitions
const int bluetoothTx = 0; // TX pin of HC-05
const int bluetoothRx = 1; // RX pin of HC-05
void setup() {
// Initialize serial communication for Bluetooth module
Serial.begin(115200);
}
void loop() {
// Check if data is available from Bluetooth module
if (Serial.available() > 0) {
char command = Serial.read();
// Forward the received command to the main controller
Serial.write(command);
}
}
Arduino Nano Code (MPU6050)
/*
* Arduino Sketch for Gesture Control Wheelchair
*
* This code interfaces with an HC-05 Bluetooth module to receive commands
* and an MPU6050 accelerometer to detect gestures. The commands are then
* forwarded to the main Arduino UNO microcontroller to control the
* wheelchair's movement.
*/
#include <Wire.h>
#include <MPU6050.h>
MPU6050 mpu;
// Pin definitions
const int bluetoothTx = 1; // TX pin of HC-05
const int bluetoothRx = 0; // RX pin of HC-05
void setup() {
// Initialize serial communication for Bluetooth module
Serial.begin(115200);
// Initialize MPU6050
Wire.begin();
mpu.initialize();
if (!mpu.testConnection()) {
while (1) {
// Failed to connect to MPU6050
}
}
}
void loop() {
// Read accelerometer data
int16_t ax, ay, az;
mpu.getAcceleration(&ax, &ay, &az);
char command = 'S'; // Default command is Stop
// Determine command based on accelerometer data
if (ax > 10000) {
command = 'F'; // Move forward
} else if (ax < -10000) {
command = 'B'; // Move backward
} else if (ay > 10000) {
command = 'L'; // Turn left
} else if (ay < -10000) {
command = 'R'; // Turn right
}
// Send command to main controller
Serial.write(command);
delay(100); // Delay to avoid spamming commands
}
This