View on GitHub

TuhinM_Portfolio

BlueStamp Summer of 2024

Engineer School Area of Interest Grade
Tuhin M Bellarmine College Preparatory Electrical Engineering and Computer Science Rising Sophomore

Gesture Controlled Robot Car

First Modification: 7/8/24

Figure 1 -- Gesture Controlled Robot Car with Ultrasonic Sensor

Figure 2 -- Gesture Controlled Robot Car with Gesture Controller

Final Milestone 6/19/24

Images

Figure 3 -- Gesture Controlled Robot Car and Controller without Modifications

Figure 4 -- Gesture Controller Robot Car and Controller without Modifications

Second Milestone 6/18/24

Images

Figure 5 -- Gesture Controller without Modifications

Figure 6 -- Gesture Controller without Modifications

First Milestone: 6/14/24

Images

Figure 7 -- Gesture Controlled Robot without Modifications

Figure 8 -- Gesture Controlled Robot without Modifications

Schematics

Figure 9 -- Schematics from Hackster.io

Figure 10 -- Schematics for the Gesture Controller

Flowchart for Code Process

Figure 11 -- Flowchart of the Code Process

Code

Test Code for Running Motors

int In1 = 7;
int In2 = 8;
int In3 = 4;
int In4 = 12;
int ENA = 5;
int ENA2 = 6;
int SPEED = 210;

void setup()
{

pinMode(In1,OUTPUT);
pinMode(In2,OUTPUT);
pinMode(In3,OUTPUT);
pinMode(In4,OUTPUT);
pinMode(ENA,OUTPUT);
pinMode(ENA2,OUTPUT);

digitalWrite(In1,HIGH);
digitalWrite(In2,LOW);
digitalWrite(In3,HIGH);
digitalWrite(In4,LOW);

analogWrite(ENA,SPEED)
analogWrite(ENA2,SPEED);

}

void loop()
{

}

Code for the Robot Car

#include <SoftwareSerial.h>
SoftwareSerial BT_Serial(2, 3);

#define enA 10
#define in1 9
#define in2 8
#define in3 7
#define in4 6
#define enB 5

char bt_data;
int Speed = 150;

void setup() {

Serial.begin(9600);
BT_Serial.begin(9600); 

pinMode(enA, OUTPUT); 
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT); 
pinMode(in3, OUTPUT); 
pinMode(in4, OUTPUT); 
pinMode(enB, OUTPUT); 

delay(200);
}
void loop(){
if(BT_Serial.available() > 0){    
bt_data = BT_Serial.read(); 
Serial.println(bt_data);          
}
  
     if(bt_data == 'f'){forward();  Speed=180;}  
else if(bt_data == 'b'){backword(); Speed=180;} 
else if(bt_data == 'l'){turnLeft(); Speed=250;} 
else if(bt_data == 'r'){turnRight();Speed=250;}
else if(bt_data == 's'){Stop(); }

analogWrite(enA, Speed); 
analogWrite(enB, Speed);

delay(50);
}

void forward(){
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
}

void backward(){ 
  digitalWrite(in1, LOW);
  digitalWrite(in2, HIGH);
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW);
}

void turnRight(){
  digitalWrite(in1, LOW);  
  digitalWrite(in2, HIGH); 
  digitalWrite(in3, LOW);
  digitalWrite(in4, HIGH);
}

void turnLeft(){
  digitalWrite(in1, HIGH);
  digitalWrite(in2, LOW); 
  digitalWrite(in3, HIGH);
  digitalWrite(in4, LOW); 
}

void Stop(){
  digitalWrite(in1, LOW); 
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
}

Code for the Gesture Controller

#include <SoftwareSerial.h>
SoftwareSerial BT_Serial(3, 2);

#include <Wire.h>

const int MPU = 0x68;
int16_t AcX, AcY, AcZ;

int flag=0;

void setup () {

  Serial.begin(9600);
  BT_Serial.begin(9600); 

  Wire.begin();
  Wire.beginTransmission(MPU);
  Wire.write(0x6B);
  Wire.write(0);
  Wire.endTransmission(true);

  delay(500); 
}

void loop () {
  Read_accelerometer();

  if (AcX<60  && flag==0) {
    flag=1;
    BT_Serial.write('f');
  }
  if (AcX>130 && flag==0) {
    flag=1;
    BT_Serial.write('b');
  }
        
  if (AcY<60  && flag==0) {
    flag=1;
    BT_Serial.write('l');
  }
  if (AcY>130 && flag==0) {
    flag=1;
    BT_Serial.write('r');
  }
    
  if((AcX>70) && (AcX<120) && (AcY>70) && (AcY<120) && (flag==1)) {
    flag=0;
    BT_Serial.write('s');
  }

  delay(100);  
}

void Read_accelerometer(){
  Wire.beginTransmission(MPU);
  Wire.write(0x3B);
  Wire.endTransmission(false);
  Wire.requestFrom(MPU, 6, true);

  AcX = Wire.read() << 8 | Wire.read();
  AcY = Wire.read() << 8 | Wire.read();
  AcZ = Wire.read() << 8 | Wire.read();

  AcX = map(AcX, -17000, 17000, 0, 180);
  AcY = map(AcY, -17000, 17000, 0, 180);
  AcZ = map(AcZ, -17000, 17000, 0, 180);

  Serial.print(AcX);
  Serial.print("\t");
  Serial.print(AcY);
  Serial.print("\t");
  Serial.println(AcZ); 
}

Code for the Bluetooth Connection

#include <SoftwareSerial.h>

SoftwareSerial Bluetooth(3, 2);

void setup() 
{
  Serial.begin(9600);
  Bluetooth.begin(38400);
}

void loop(){
  if (Bluetooth.available())
    Serial.write(Bluetooth.read());
  
  if (Serial.available())
    Bluetooth.write(Serial.read());
}

Bill of Materials

Part Note Price Link
Arduino UNO Used to control the robot movement $25.81 Link
Arduino Nano R3 Used for the hand mounted part $23.23 Link
Inertial Measurement Unit (IMU) (6 deg of freedom) Used for sensing changes and movement $5.99 Link
SparkFun Dual H-Bridge motor drivers L298 Used to control the motors $7.21 Link
Solderless Breadboard Half Size Used to hold the pins and devices for the controller $4.96 Link
HC-05 Bluetooth Module Used for connecting the robot car to the controller on the wrist $10.39 Link
Male/Male Jumper Wires Used to connect electronics to the boards $2.10 Link
Male/Female Jumper Wires Used to connect electronics to the boards $4.11 Link
DC Motor, 12 V Used to make the robot move $2.10 Link
Pimoroni Maker Essentials - Micro-motors & Grippy Wheels Used to translate the motor power to movement $33.79 Link
Rocker Switch, SPST Used to switch the robot and controller on and off $1.26 Link
9V Battery Clip Used to connect to the battery pack $0.309 Link
9V battery (generic) Used to power the robot $1.54 Link
Battery Holder, 18650 x 2 Used to hold the batteries $9.48 Link
Arduino IDE Used to code the functionalities of the robot $0.00 Link

Other Resources/Examples

Arduino Starter Project: 6/12/24

Code

#define LED_PIN 8
#define BUTTON_PIN 7

void setup() {
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT);
}
void loop() {
  if (digitalRead(BUTTON_PIN) == HIGH) {
    digitalWrite(LED_PIN, HIGH);
  }
  else {
    digitalWrite(LED_PIN, LOW);
  }
}

Bill of Materials

Part Note Price Link
Arduino Uno Control the circuit power and ground $24.50 Link
USB A -> B cable Connection to computer $9.89 Link
Arduino Proto Shield Used to make easier wire connections $9.95 Link
Breadboard Used to hold LED, Button, and wiring $2.90 Link
Male to Male Connectors Used to connect electronics $2.10 Link