Guesture Controlled Robot
My project is a guesture controlled robot. This project has two seperate parts, the robot, and the controller. The robot part of this project has 4 wheels and can drive around. The controller uses a bluetooth conection to the robot to tell it what to do, which is decided by the controller based on an accelerometr that is used to detect the motion of the controller. This means that by moving the controller in a certain way, you will be able to move the robot.
Engineer | School | Area of Interest | Grade |
---|---|---|---|
Nolan S. | Alameda High | Computer Science | Incoming Senior |

Final Milestone
My final milestone was completing the entire project.
- Since the last milestone, I have written all of the code and connected the accelerometer to the controller.
- The hardest part about this project was due to the project having both hardware and software. This meant that if there was an error, I had to check both the hardware and the software. Because of this I was constantly double checking my wiring and my code in order for the whole project to continue working.
- While doing this project, I learned a lot about the hardware side of engineering, which is what I came to bluestamp for in the first place.
- Overall, I had a great time while doing this project and hope that in the future I will be able to do more projects like this.
Second Milestone
My second milestone was figuring out how to connect and configure the two bluetooth modules.
- I put both modules in pairing mode and sent commands to each to pair them.
- Putting them in pairing mode was a difficult task because there was a lot of wiring and power issues that I experienced while doing it. If wires were in the wrong place or if they were suppling too much power, it would look like it was in pairing mode, but none of the pairing commands would work.
- Eventually I figured this out and was able to pair the two modules.
- Before completing my final milestone, I still have to connect the accelerometer to the controller and write all of the code for the project.
First Milestone
My first milestone was getting the robot part of the project to work.
- This involved attaching the motors, wheels, Arduino, battery pack, and motor driver board to the chassis. I then had to correctly connect all of the parts together with wires.
- The hardest part about connecting the wires was finding the correct place to connect each wire. This is due to the fact that the motors are not oriented in the exact same way on the chassis so when attatching the wires I had to account for the orientation of the motor relative to all of the other motors.
- I then connected the arduino to my computer and was able to run code that made the robot drive.
- A challenge that I am going to have to solve in future milestones is the wiring of my robot. The wire ends are currently connected by being bent together. This can lead to malfunctions due to the wires not touching eachother correctly. To solve this I need to sauter the wires into their correct places but this may prove a challenge because I have never sautered anything before.

Schematics

Code
//Code for the car
// This is to receive data from the other bluetooth module and read the gestures
// The robot should move accordingly!
#include <SoftwareSerial.h>
#define tx 2
#define rx 3
SoftwareSerial configBt(rx, tx);
//character variable for command
char c = "";
//start at 50% duty cycle
//int s = 120;
//change based on motor pins
int in1 = 4;
int in2 = 5;
int in3 = 6;
int in4 = 7;
void setup()
{
//opens serial monitor and bluetooth serial monitor
Serial.begin(38400);
configBt.begin(38400);
pinMode(tx, OUTPUT);
pinMode(rx, INPUT);
//initializes all motor pins as outputs
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}
void loop()
{
//checks for bluetooth data
if (configBt.available()){
//if available stores to command character
c = (char)configBt.read();
//prints to serial
Serial.println(c);
}
//acts based on character
switch(c){
//forward case
case 'F':
forward();
break;
//left case
case 'L':
left();
break;
//right case
case 'R':
right();
break;
//back case
case 'B':
back();
break;
//default is to stop robot
case 'S':
freeze();
}
}
//moves robot forward
void forward(){
//chages directions of motors
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
}
//moves robot left
void left(){
//changes directions of motors
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
}
//moves robot right
void right(){
//changes directions of motors
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
}
//moves robot backwards
void back(){
//changes directions of motors
digitalWrite(in1, HIGH);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
}
//stops robot
void freeze(){
//changes directions of motors
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}
//Code for the controller
#include <Wire.h>
#define MPU6050_ADDRESS 0x68
int16_t accelerometerX, accelerometerY, accelerometerZ;
void setup()
{
Wire.begin();
Serial1.begin(38400);
// Initialize MPU6050
Wire.beginTransmission(MPU6050_ADDRESS);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU6050)
Wire.endTransmission(true);
delay(100); // Delay to allow MPU6050 to stabilize
}
void loop()
{
readAccelerometerData();
determineGesture();
delay(500);
}
void readAccelerometerData()
{
Wire.beginTransmission(MPU6050_ADDRESS);
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(MPU6050_ADDRESS, 6, true); // request a total of 6 registers
// read accelerometer data
accelerometerX = Wire.read() << 8 | Wire.read();
accelerometerY = Wire.read() << 8 | Wire.read();
accelerometerZ = Wire.read() << 8 | Wire.read();
}
void determineGesture()
{
if (accelerometerY >= 6500) {
Serial1.write('F');
}
else if (accelerometerY <= -4000) {
Serial1.write('B');
}
else if (accelerometerX <= -3250) {
Serial1.write('L');
}
else if (accelerometerX >= 3250) {
Serial1.write('R');
}
else {
Serial1.write('S');
}
}
Bill of Materials
Part | Note | Price | Link |
---|---|---|---|
Smart Car Kit | The body and motors of the car | 18.99 | Amazon |
2 Bluetooth Modules | Communication between the two parts | 20.78 | Amazon |
Arduino Uno | Controlling the Car | 24.00 | Arduino |
Arduino Micro | Controlling the Controller | 21.60 | Arduino |
Motor Driver Board | Controlling the Motors | 6.99 | Amazon |
Breadboards | Solderless Circuits | 9.99 | Amazon |
Soldering Kit | Soldering all Wires | 30.00 | Amazon |
Velcro | Attaching parts to the Car | 9.99 | Amazon |
Wires | Connecting all the parts | 16.94 | Amazon |
Batteries | Power | 9.70 | Amazon |
Battery Holder | Power | 6.99 | Amazon |