Wednesday, January 6, 2016

Arduino Bluetooth RC Car (Android Controlled) 


Hello. In this project i'm going to make a Arduino Controlled car using HC-05 bluetooth module.
Before starting, make sure that you have:
  • Arduino uno board
  • L293D motor driver
  • HC-05 Bluetooth module
  • Motors ( in my case i'm using 4 gear motors )
  • power regulator
  • Rechargeable battery.

1. Circuit Diagram


I uploaded similer circuit diagram which i used.In my case i used Arduino Mega bord.Above diagram i did nnt mention about the power unit in my robot i used buck converter.i think you know about these things.


  • Make sure your bluetooth module is connected corectly as my diagram it should be RX in to TX and TX in to RX like that.




2.It's quite simple if you complete basic things to programme.

First of all you should initialize the D2,D3,D4,D5 in to some digital pins to control the motors and to control the speed you should  initialize 2 PWM pins.It's not need any way you can just give some 5v to those two pins in the motor drive it will work fine then you cant change the speed.

to the controlling part i'am using this android app and it's very simple to use.if you click on the button it will send some specific ASCII values to the arduino and there is another feature of this app it will remainly send that value if you hold the button it will stop after you release the finger.it's  the best app i ever seen in the play store for this purpose

https://play.google.com/store/apps/details?id=braulio.calle.bluetoothRCcontroller&hl=en

int in1 = 9;
int in2 = 10;
int in3 = 11;
int in4 = 12;
int speedPinA = 8;
int speedPinB = 13;

int inByte = 0;   
//---------------------------------------------------------------
void setup(){
  
 Serial.begin(9600);
//----------------------------
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(speedPinA,OUTPUT);
  pinMode(speedPinB,OUTPUT);
}
void forwd(){
        analogWrite(speedPinA, 250);
        analogWrite(speedPinB, 250);
        
        digitalWrite(in1,LOW);
        digitalWrite(in2, HIGH);
        
        digitalWrite(in3,HIGH);
        digitalWrite(in4, LOW);
}

void Left(){
        analogWrite(speedPinA, 250);
        analogWrite(speedPinB, 250);
        
        digitalWrite(in1,LOW);
        digitalWrite(in2, HIGH);
        
        digitalWrite(in3,LOW);//-------
        digitalWrite(in4, HIGH);
}
void backwrd(){
   analogWrite(speedPinA, 250);
   analogWrite(speedPinB, 250);
   
        digitalWrite(in1,HIGH);
        digitalWrite(in2, LOW);
        
        digitalWrite(in3,LOW);
        digitalWrite(in4, HIGH);
}
void Right(){
   analogWrite(speedPinA, 250);
   analogWrite(speedPinB, 250);
        
        digitalWrite(in1,HIGH);
        digitalWrite(in2, LOW); //----
        
        digitalWrite(in3,HIGH);
        digitalWrite(in4,LOW);
}
void all_stop(){
        digitalWrite(in1,LOW);
        digitalWrite(in2, LOW);
        
        digitalWrite(in3,LOW);
        digitalWrite(in4, LOW);
}

void loop(){
   if (Serial.available() > 0) {   
       
    inByte = Serial.read(); 
    Serial.println(inByte);
 //--------------------------------------------------------------
    if(inByte == 76){
        Right();
        inByte = 0;     
    }
    if(inByte == 82 ){
        Left();
        inByte = 0;
    }
    //----------------------------------------------------------------
      if(inByte == 70){ 
        forwd();
        inByte = 0;     
    }
    if(inByte == 66){
        backwrd();
        inByte = 0;
    } 
    if(inByte == 83 ){
        all_stop();
    }
  }



3.Finished



Enjoy it.....!