Mobile Controlled Car


A robot which can be controlled by mobile phone using a joystick on an android application. The communication of mobile phone and Arduino is achieved with the use of Bluetooth.

Smartphones have become the most essential thing in our daily life. Android application based smartphones are becoming each time more powerful and equipped with several accessories that are useful for Robots. This project describes a robot which is controlled using mobile through Bluetooth communication.

Here I have used a Bluetooth module to establish a Bluetooth communication between Arduino and mobile phone. It connects to the mobile using the given application. Once the module is connected, signals from app can be sent to the Arduino. The signals received are manipulated and are then sent to the motors for appropriate movement of the car. Accelerometer mode can also be used which uses the accelerometer of the mobile phone to control the robot. In this mode, the robot is actually driven by tilting of the phone.

The novelty lies in the fact that it is a cost-effective project with a simple and easy to use interface. Such small robots can be used in spying and surveillance purposes. With few additions and modifications, this robot can be used in the army for detecting and disposing of hidden land mines.

Components :

  • Arduino Uno
  • L293D(Motor Driver)
  • Motors x 2
  • LM 7805 Voltage Regulator
  • IR Sensors x 2
  • Bread Board
  • Chassis(of appropriate size)
  • Jumper Wires
  • Battery (Power Source)
  • Bluetooth Module HC-05
You can find the app here
The app gives reading as :

Connections :

The motor connections are here
Bluetooth module connections:

Code:

  
int lmotor1=10;
int rmotor1=5;
int lmotor2=11;
int rmotor2=6;

byte commands[4]={0,0,0,0};

void setup()
{
  //initialisations
  pinMode(lmotor1, OUTPUT);
  pinMode(lmotor2, OUTPUT);
  pinMode(rmotor1, OUTPUT);
  pinMode(rmotor2, OUTPUT);
  analogWrite(lmotor1, 0);
  analogWrite(lmotor2, 0);
  analogWrite(rmotor1, 0);
  analogWrite(rmotor2, 0); 

 Serial.begin(9600);
}

void loop(){
  // put your main code here, to run repeatedly:
  if(Serial.available()>4)
  {
                                                  // if the first byte read is not the first byte sent from the bluetooth skip it and read the next byte
    while(1)
    {
      commands[0] = Serial.read();
                                                 // check if the first byte value corresponds to those sent by the app over bluetooth
      if(commands[0]==241 || commands[0]==242 || commands[0]==243)
        break;
    }
                                                  // read the next 3 bytes as well
    commands[1] = Serial.read();  //Speed
    commands[2] = Serial.read();  //Angle
    commands[3] = Serial.read();
                                                    // neutral : 243 0 88 0
      Serial.print(commands[0]);
      Serial.print(" ");
      Serial.print(commands[1]);
      Serial.print(" ");
      Serial.print(commands[2]);
      Serial.print(" ");
      Serial.println(commands[3]);
    
    int recTurnSpeed = commands[2];
  
     if(commands[0] == 241){
      
       Serial.println("FORWARD");
         if(recTurnSpeed > 88){
       
          Serial.println("RIGHT");

          analogWrite(lmotor1, 1010);
          analogWrite(lmotor2, 0);
          analogWrite(rmotor1, 0);
          analogWrite(rmotor2, 1010);
        }
        
        else if(recTurnSpeed < 88){
 
           
           Serial.println("LEFT");

           analogWrite(lmotor1, 0);
          analogWrite(lmotor2, 1010);
          analogWrite(rmotor1, 1010);
          analogWrite(rmotor2, 0);
        }
        
        else{
          analogWrite(lmotor1, 1010);
          analogWrite(lmotor2, 0);
          analogWrite(rmotor1, 1010);
          analogWrite(rmotor2, 0);
        }
     }
    
     else if(commands[0] == 242){
      
       Serial.println("BACK");
       if(recTurnSpeed > 88){
       
          Serial.println("RIGHT");

          analogWrite(rmotor1, 1010);
          analogWrite(rmotor2, 0);
          analogWrite(lmotor1, 0);
          analogWrite(lmotor2, 1010);
        }
        
        else if(recTurnSpeed < 88){
 
           
           Serial.println("LEFT");

           analogWrite(rmotor1, 0);
          analogWrite(rmotor2, 1010);
          analogWrite(lmotor1, 1010);
          analogWrite(lmotor2, 0);
        }
        
        else{
          analogWrite(rmotor1, 0);
          analogWrite(rmotor2, 1010);
          analogWrite(lmotor1, 0);
          analogWrite(lmotor2, 1010);
        } 
    }
    
    else if(commands[0] == 243){
       analogWrite(lmotor1, 0);
          analogWrite(lmotor2, 0);
          analogWrite(rmotor1, 0);
          analogWrite(rmotor2, 0);
      
    }
  }
}   
  

Comments

Popular posts from this blog

Three Wheeled Omnidirectional Robot : Motion Analysis

The move_base ROS node

Overview of ATmega328P