achyutayadunandan
Published © GPL3+

Phone Bluetooth-Controlled RC Car

This project aims to implement interesting methods of driving an RC car right from your phone!

IntermediateShowcase (no instructions)5,528
Phone Bluetooth-Controlled RC Car

Things used in this project

Hardware components

RC Car
Any RC car, truck, etc will work as long as it is 2WD with front wheels steering
×1
Arduino UNO
Arduino UNO
Any Arduino board could be used for this project. The Mega is being used in the truck and the Nano is being used in the car.
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
Make sure to get HC-05, not the HC - 06 module. The HC - 05 module allows for data to be both sent and received (acting as both master and slave), while the HC - 06 only allows for data to be received (slave).
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
Buzzer
Buzzer
×1
Li-Ion Battery 1000mAh
Li-Ion Battery 1000mAh
I used two 3.7 Volt 9900 mAh batteries
×2
General Purpose Transistor NPN
General Purpose Transistor NPN
×1
Resistor 1k ohm
Resistor 1k ohm
Two for voltage divider, one for buzzer
×3
Through Hole Resistor, 680 ohm
Through Hole Resistor, 680 ohm
As part of the voltage divider
×1
Through Hole Resistor, 470 ohm
Through Hole Resistor, 470 ohm
For LED
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
LED (generic)
LED (generic)
×1

Software apps and online services

MIT App Inventor 2
MIT App Inventor 2
Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Multitool, Screwdriver
Multitool, Screwdriver
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Mastech MS8217 Autorange Digital Multimeter
Digilent Mastech MS8217 Autorange Digital Multimeter

Story

Read more

Custom parts and enclosures

.stl File for 3D printing a steering wheel for the phone while in tilt mode

Schematics

rcCarDriverSchematic

Image of Schematic (General pins: exact pins can vary)

Code

rcCarBluetoothControl

Arduino
#include <SoftwareSerial.h>

#define TxD 12 // bluetooth connection pins
#define RxD 2

#define MOTOR_FORWARD 9 // motor pins
#define MOTOR_BACKWARD 10
#define MOTOR_LEFT 5
#define MOTOR_RIGHT 6

#define LED_PIN 13
#define BUZZER 33
#define BATTERY_VOLTAGE A0

SoftwareSerial bluetoothSerial(TxD, RxD); // software serial object

int c;
int speedIntensity = 192; // start at 3/4 max speed (where app slider begins)
double batteryVoltageIn;
double batteryVoltage;
boolean ledOn = false;
boolean inMotion = false;
boolean goingForward = true;

void setup() {
  bluetoothSerial.begin(9600);
  Serial.begin(9600);
  
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUZZER, OUTPUT);
  pinMode(BATTERY_VOLTAGE, INPUT);
  
  pinMode(MOTOR_FORWARD, OUTPUT);
  pinMode(MOTOR_BACKWARD, OUTPUT);
  pinMode(MOTOR_LEFT, OUTPUT);
  pinMode(MOTOR_RIGHT, OUTPUT);   
}

void loop() {
  // Accelerometer: 99 up, 98 down, 100 right, 101 left, 102 stop
  if (bluetoothSerial.available()){ // if bluetooth signal available, it is stored in int c; all numbers recieved pre-coded in app
    c = bluetoothSerial.read();
    Serial.println(c);
    if (c == 1 || c == 99){ // value from btn. mode and acc. mode
      forwardSpeed(speedIntensity);
      inMotion = true;
      goingForward = true;
    }
    else if (c == 2 || c == 98){
      inMotion = true;
      backwardSpeed(speedIntensity);
      goingForward = false;
    }
    else if (c == 3 || c == 101){
      leftTurn();
    }
    else if (c == 4 || c == 100){
      rightTurn();
    }
    else if (c == 0 || c == 102){
      inMotion = false;
      halt();
    }
    else if (c == 5){ // changes LED's state
      ledOn = !ledOn;
      if (ledOn){
        digitalWrite(LED_PIN, HIGH);
      }
      else if (!ledOn){
        digitalWrite(LED_PIN, LOW);
      }
    }
    else if (c >= 10 && c <= 50){ // changes speed based on slider position
      speedIntensity = map(c, 10, 50, 0, 255);
      if (inMotion){
        if (goingForward){
          forwardSpeed(speedIntensity);
        }
        else if (!goingForward){
          backwardSpeed(speedIntensity);
        }
      }
    }
    else if (c == 6){
      digitalWrite(BUZZER, HIGH);
    }
    else if (c == 7){
      digitalWrite(BUZZER, LOW);
    }
    else if (c == 51){
      digitalWrite(LED_PIN, HIGH);
    }
    else if (c == 52){
      digitalWrite(LED_PIN, LOW);
    }
    else if (c == 8){
      batteryVoltageIn = (double)analogRead(BATTERY_VOLTAGE) / 204.6;
      batteryVoltage = (8.0/5.0) * batteryVoltageIn; // converts reading to voltage of 8V battery
      if (batteryVoltage >= 7.40){ // sends code to specify which of 4 battery levels car is at
        bluetoothSerial.write(60);            
      }
      else if (batteryVoltage >= 6.90){
        bluetoothSerial.write(61);
      }
      else if (batteryVoltage >= 6.40){
        bluetoothSerial.write(62);
      }
      else{
        bluetoothSerial.write(63);
      }
    }
  }
}

void rightTurn(){
  digitalWrite(MOTOR_LEFT, LOW);
  digitalWrite(MOTOR_RIGHT, HIGH);
}

void leftTurn(){
  digitalWrite(MOTOR_LEFT, HIGH);
  digitalWrite(MOTOR_RIGHT, LOW);
}

void forwardSpeed(int speedInput){
  analogWrite(MOTOR_FORWARD, speedInput);
  digitalWrite(MOTOR_BACKWARD, LOW);
  digitalWrite(MOTOR_LEFT, LOW);
  digitalWrite(MOTOR_RIGHT, LOW);
}

void backwardSpeed(int speedInput){
  digitalWrite(MOTOR_FORWARD, LOW);
  analogWrite(MOTOR_BACKWARD, speedInput);
  digitalWrite(MOTOR_LEFT, LOW);
  digitalWrite(MOTOR_RIGHT, LOW);
}

void halt(){
  digitalWrite(MOTOR_FORWARD, LOW);
  digitalWrite(MOTOR_BACKWARD, LOW);
  digitalWrite(MOTOR_LEFT, LOW);
  digitalWrite(MOTOR_RIGHT, LOW);  
}

Credits

achyutayadunandan

achyutayadunandan

1 project • 0 followers

Comments