Tuesday, 20 December 2016

Control the car with your phone (Arduino)


1. INTRODUCTION


This project is about building a two wheel mobile robot that could be controlled using your Android smartphone via Bluetooth. The robot uses a HC-05 Bluetooth module interfaced to an Arduino UNO.

Firstly before I assemble the robot i build a prototype circuit with the entire electronic component required to operate the robot. Before assembling the circuit to the robot base, I tested the circuit
and the programe sequence using a software call FLOWLOGIC 6 allow me to test each electronic component such as DC motor, sonor sensor, push buttons etc. Manually using various flowchart command blocks. Upon testing, troubleshooting and debugging proses, I begin to develop embedded proses . I begin to develop embeded my robot control program in C++ language using ARDUINO IDE.

The embedded program contains multiple function such as setup, loop, motor foward, motor reverse, motor right, motor left, motor stop. After completing codding the program I compile it and upload option that is available in the ARDUINO IDE. During compiling and uploading proses restify number of program errors that occured.




2. THE CONTROL CIRCUIT
3.ROBOT EMBEDED C++ CONTROLL PROGRAM


 * MY MOBILE ROBOT  PROGRAM
 *
 *
 * DEVELOPED BY: S.PRAVEEN RAJA
 * 16 DECEMBER 2016
 */
#include <NewPing.h>;
 byte serial
int sv;
#define TRIGGER_PIn12  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN11  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
#define m1speed 5
#define m1fwd 6
#define m1rev 7
#define m2speed 10
#define m2fwd 9
#define m2rev 8
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
void setup(){
Serial.begin(9600); // Open serial monitor at 115200 baud to see ping result
pinMode(2,INPUT);
pinMode(3,INPUT);
  pinMode(4,INPUT);
  pinMode(m1fwd,OUTPUT);
  pinMode(m1rev,OUTPUT);
  pinMode(m2fwd,OUTPUT);
  pinMode(m2rev,OUTPUT);
}
Void loop ()
{
  delay(50);                // Wait 50ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
 unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
 sv = (uS / US_ROUNDTRIP_CM);
 Serial.println(sv);
    if (sv < 4)
    {
    STOP();
    Serial.println("4") ;          
  if (Serial.available()>0)
  {
    serialA=Serial.read();
    Serial.println(serialA);
    switch (serialA)
    {
      case 49 :
      fwd()
     break;
   
     case 50 :
     rev();
     break;

     case 51 :
     left();
     break;

     case 52 :
     right();
     break;
   
     case 53 :     
     STOP();
     break;
  }
  }
  if (digitalRead(2) == 1)
  {
    fwd();
  }
   if (digitalRead(3) == 1)
   {
    rev();
   }
  if (digitalRead(4) == 1)
  {
  STOP();
}
}
void fwd()
{
    Serial.println("fwd");
  analogWrite(m1speed,255);
  digitalWrite(m1fwd,HIGH);
  digitalWrite(m1rev,LOW);
  analogWrite(m2speed,255);
  digitalWrite(m2fwd,HIGH);
  digitalWrite(m2rev,LOW);
}
void rev()
{
  Serial.println("rev");
  analogWrite(m1speed,255);
  digitalWrite(m1fwd,LOW);
  digitalWrite(m1rev,HIGH);
  analogWrite(m2speed,255);
  digitalWrite(m2fwd,LOW);
  digitalWrite(m2rev,HIGH);
}
void STOP(){
  Serial.println("STOP");
   analogWrite(m1speed,0);
  digitalWrite(m1fwd,LOW);
  digitalWrite(m1rev,LOW);
  analogWrite(m2speed,0);
  digitalWrite(m2fwd,LOW);
  digitalWrite(m2rev,LOW);
}
 void left()
{
  Serial.println("left");
  analogWrite(m1speed,255);
  digitalWrite(m1fwd,LOW);
  digitalWrite(m1rev,LOW);
  analogWrite(m2speed,255);
  digitalWrite(m2fwd,HIGH);
  digitalWrite(m2rev,LOW);
}
void right()
 {
    Serial.println("right");
  analogWrite(m1speed,255);
  digitalWrite(m1fwd,HIGH);
  digitalWrite(m1rev,LOW);
  analogWrite(m2speed,255);
  digitalWrite(m2fwd,LOW);

 digitalWrite(m2rev,LOW);}

4. ROBOT APP USING MIT APP INVENTOR

BLOKS FOR BLUETOOTH CONNECTION  SELECTION









BLOKS FOR ROUTINE BLUTOOTH CONNECTION


BLOKS FOR MOTOR CONTROLLER












5.ROBOT COMPONENT


I HAVE UPLOADED A VIDEO TO SHOW IT"S WORK






THERE WERE SUBTITLE IN THIS VIDEO


HAPPY ROBOTING😊😊😊😊


3 comments:

  1. HI THERE IF HAVE ANY QUESTION OR MISTAKES PLS LEAVE YOUR COMMENT

    ReplyDelete
  2. AND IF YOU LIKE THIS ARTICLE PLEASE LEAVE (+1) VIA GOOGLE PLUS OUR LEAVE COMMENT

    ReplyDelete
  3. if u see this blog ps leave comment or +1 as your support

    ReplyDelete