RoboGear
Published © GPL3+

Bluetooth-Controlled Car

How to make a Bluetooth-controlled car.

IntermediateShowcase (no instructions)5,480
Bluetooth-Controlled Car

Things used in this project

Story

Read more

Schematics

circuit design of bluetooth control car

its all about schematic diagram of connecting arduino + l293d + hc 05 with a robot car

Code

BLUETOOTH CONTROL CAR CODE

C/C++
ARDUINO CODE FOR BLUETOOTH CONTROL CODE
#define LMP  2
#define LMN  4
#define RMP  7
#define RMN  5


int firstSensor = 0;         // first analog sensor
int secondSensor = 0;    // second analog sensor
int thirdSensor = 0;        // digital sensor
int inByte = 0;               // incoming serial byte
char BYTE;
boolean status_unlock;
boolean status_bluetooth;

long interval = 1000;           // interval at which to blink (milliseconds)
long previousMillis = 0;        // will store last time LED was update
int minite,sec;


void setup()
{
  // start serial port at 9600 bps:
  Serial.begin(9600);
  //pinMode(2, INPUT);   // digital sensor is on digital pin 2
  establishContact();    // send a byte to establish contact until receiver responds 
  
  pinMode(LMP, OUTPUT);
  pinMode(LMN, OUTPUT);
  pinMode(RMP, OUTPUT);
  pinMode(RMN, OUTPUT);


  
  digitalWrite(LMP, LOW);  // switch off MOTOR
  digitalWrite(LMN, LOW);  // switch off MOTOR
  digitalWrite(RMP, LOW);  // switch off MOTOR
  digitalWrite(RMN, LOW);  // switch off MOTOR
    

  status_bluetooth = true;
  status_unlock = false;
  sec = 0;
}

void loop()
{
  if (Serial.available() > 0)
  {   
       
    inByte = Serial.read();                      // get incoming byte:  

 if(inByte == 'A')
    {    
      digitalWrite(LMP, HIGH);         
      digitalWrite(LMN, LOW);
      digitalWrite(RMP, HIGH);
      digitalWrite(RMN, LOW);
            
      inByte = 0;     
    }    
   
    if(inByte == 'B')
    {    
      digitalWrite(LMP, LOW);         
      digitalWrite(LMN, HIGH);
      digitalWrite(RMP, LOW);
      digitalWrite(RMN, HIGH);
    
                      
      inByte = 0;     
    }
        
    if(inByte == 'D')
    {    
       digitalWrite(LMP, HIGH);         
      digitalWrite(LMN, LOW);
      digitalWrite(RMP, LOW);
      digitalWrite(RMN, LOW);
          
      inByte = 0;     
    }
    
   if(inByte == 'C')
    {    
      digitalWrite(LMP, LOW);         
      digitalWrite(LMN, LOW);
      digitalWrite(RMP, HIGH);
      digitalWrite(RMN, LOW);
    
      Serial.print('D', BYTE);                  
      inByte = 0;     
    }
       
    if(inByte == 'E')
    {    
      digitalWrite(LMP, LOW);         
      digitalWrite(LMN, LOW);
      digitalWrite(RMP, LOW);
      digitalWrite(RMN, LOW);
    
     
      Serial.print('E', BYTE);                   
      inByte = 0;     
    }
    
  if(inByte == 'G')
    {    
     digitalWrite(LMP, HIGH);         
      digitalWrite(LMN, LOW);
      digitalWrite(RMP, LOW);
      digitalWrite(RMN, HIGH);
        
      inByte = 0;     
    }
    
    if(inByte == 'F'){    
       digitalWrite(LMP, LOW);         
      digitalWrite(LMN, HIGH);
      digitalWrite(RMP, HIGH);
      digitalWrite(RMN, LOW);
     
      
      Serial.print('G', BYTE);  
      inByte = 0;     
    }
    
  
    
    if(inByte == 'S'){    
      
      Serial.print('S', BYTE);                  // send a char
      status_bluetooth = true;
      sec = 0;
          
    }    
  } // if(Serial
  
  /*
  unsigned long currentMillis = millis();
      
              if(currentMillis - previousMillis > interval) {            
                previousMillis = currentMillis;         // save the last time you blinked the LED 
                
                sec++;
                
                if(status_unlock==true){
                
                  if(sec== 11){
                
                      digitalWrite(LED_PIN1, HIGH);        // switch on LED
                
                      delay(800);
                      digitalWrite(LED_PIN1, LOW);        // switch off LED
                
                      status_unlock = false;                  
                      sec = 0;
                  }
                }
                else sec = 0;                
                
              }
  
 */ 
    
} //Loop

void establishContact() {
  while (Serial.available() <= 0) {
    Serial.print('.', BYTE);                   // send a capital A
    delay(500);
  }
}

Credits

RoboGear

RoboGear

0 projects • 6 followers

Comments