jegatheesan
Published © GPL3+

Easy Hack RC to RC and BT Car Using Linkit One

Plan to change a RC car to blue tooth car. Because RC car is just (6 $)

IntermediateFull instructions provided2,031
Easy Hack RC to RC and BT Car Using Linkit One

Things used in this project

Hardware components

4 relay module
×1
RC Car
×1
5v Power Adapter
×1
Android device
Android device
×1

Software apps and online services

Arduino IDE
Arduino IDE
Bluetooth RC Car app

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Code

BTControlcar.ino

Arduino
#include <LBT.h>
#include <LBTServer.h>
int readval;

int rightbtn=10;
int leftbtn=11;
int frontbtn=12;
int backbtn=13;

int rstatus=0;
int lstatus=0;
int fstatus=0;
int bstatus=0;

String readchr;
String prevreadchr;


void setup() {
 if(!LBTServer.begin((uint8_t*)"Sivam_LIO"))
 {
 return;
 }
// Serial.begin(9600); 
 
  pinMode(rightbtn, OUTPUT);
  pinMode(leftbtn, OUTPUT);
  pinMode(frontbtn, OUTPUT);
  pinMode(backbtn, OUTPUT);  
  
  digitalWrite(rightbtn, LOW);
  digitalWrite(leftbtn, LOW);
  digitalWrite(frontbtn, LOW);
  digitalWrite(backbtn, LOW);
}

void loop() {
 uint8_t buf[1];
 int bytesRead;
 if(LBTServer.connected())
 {
 while(true)
 {
 bytesRead = LBTServer.readBytes(buf, 1);
 if(!bytesRead)
 break;
 readval = buf[0];
 readchr="";
 readchr+=char(readval);
 control();
//  Serial.print(readchr);
 }
 delay(100);
 }
 else
 {
 LBTServer.accept(5);
  digitalWrite(rightbtn, LOW);
  digitalWrite(leftbtn, LOW);
  digitalWrite(frontbtn, LOW);
  digitalWrite(backbtn, LOW); 
 }
}


void control()
{
  fstatus=0;
  bstatus=0;
  lstatus=0;
  rstatus=0;
  if (readchr=="F"){
   fstatus = 1;   
  }
  else if (readchr=="B"){
    bstatus=1;
  }
  else if (readchr=="L") { 
    lstatus=1;
  }
  else if (readchr=="R") {
    rstatus=1;
  }
  else if (readchr=="G" || readchr=="I") {
    fstatus = 1;    
    if (readchr=="G"){
      lstatus=1;      
    }
    else{
      rstatus=1;      
    }
  }
  else if (readchr=="H" || readchr=="J") {  
    bstatus = 1;    
    if (readchr=="G"){
      lstatus=1;      
    }
    else{
      rstatus=1;      
    }
  }
  
  //Serial.println(readchr);
  
  if(prevreadchr!=readchr)  
  {
    prevreadchr=readchr;
//    Serial.println(rstatus);
//    Serial.println(rstatus);  
//    Serial.println(lstatus);  
//    Serial.println(fstatus);  
//    Serial.println(bstatus);    
    
    if (rstatus==0)
    {
    digitalWrite(rightbtn, LOW);  
    }else
    {
    digitalWrite(rightbtn, HIGH);  
    }
    
    if (lstatus==0)
    {
    digitalWrite(leftbtn, LOW);  
    } else
    {
    digitalWrite(leftbtn, HIGH);  
    }
    
    if (fstatus==0)
    {
    digitalWrite(frontbtn, LOW);  
    }else
    {
    digitalWrite(frontbtn, HIGH);  
    }
    
    if (bstatus==0)
    {
    digitalWrite(backbtn, LOW);  
    }else
    {
    digitalWrite(backbtn, HIGH);  
    }      
  }
}

Credits

jegatheesan

jegatheesan

16 projects • 43 followers
Simply A Mechatronics Lover.

Comments