Project showcase
How to Make a Smart RC Car with Steering Wheel Remote

How to Make a Smart RC Car with Steering Wheel Remote © GPL3+

A remote control car controlled with a steering wheel using mpu6050 sensor and rf434.

  • 1,993 views
  • 0 comments
  • 5 respects

Components and supplies

About this project

Code

smart rc car with steering wheel remoteC/C++
#include<Wire.h>
long accelx,accely,accelz; // define accelerometer variables
float gforcex,gforcey,gforcez;
int irsensorbackward=A0; 
 // same for backward direction
int pin13=12; // pin13,pin12,pin11,pin10 these pins are the data pin of ht12e ic 
int pin12=10;
int pin11=8;
int pin10=7;
int value; // this takes the analog reading of irsensorbackward 

void setup()
{
  Serial.begin(9600);
  Wire.begin(); // initialising
  
  pinMode(irsensorbackward,INPUT);
  pinMode(pin13,OUTPUT);
  pinMode(pin12,OUTPUT);
  pinMode(pin11,OUTPUT);
  pinMode(pin10,OUTPUT);
  
  setupmpu(); // call the function
}
void loop()
{
    value=analogRead(irsensorbackward);
 accelregistervalue();
 
  
Serial.println(value); 
 
  // reading from gforcey variable only
  if(value > 255)
  {
     if(gforcey>-0.39 || gforcey<0.39)
       {
    digitalWrite(pin13,LOW);  // the car will move in the forward direction
    digitalWrite(pin12,HIGH);
    digitalWrite(pin11,LOW);
    digitalWrite(pin10,HIGH);
       }
      if(gforcey<-0.40) // if the condition will true then the car will move in the left side
        {
           digitalWrite(pin13,LOW);
           digitalWrite(pin12,HIGH);
           digitalWrite(pin11,HIGH);
           digitalWrite(pin10,HIGH);
         }
      if(gforcey>0.40) // if this condition will true then the car will turn right
        {
   
     digitalWrite(pin13,HIGH);
    digitalWrite(pin12,HIGH);
    digitalWrite(pin11,LOW);
    digitalWrite(pin10,HIGH);
        }
 }

 if(value<255) // all motors are off mode
   {
    
        digitalWrite(pin13,HIGH);
        digitalWrite(pin12,HIGH);
        digitalWrite(pin11,HIGH);
        digitalWrite(pin10,HIGH);
      
   }
}
void setupmpu()
{
  Wire.beginTransmission(0b1101000); // send slave address
  Wire.write(0x6B); // 6B regidter which i want to access
  Wire.write(0b00000000); // set all bits of these register are 0
  Wire.endTransmission();
  
  // accelerometer configuration
  Wire.beginTransmission(0b1101000);
  Wire.write(0x1c);
  Wire.write(0b00000000);
  Wire.endTransmission();
}
void accelregistervalue()
{
    Wire.beginTransmission(0b1101000);
  Wire.write(0x3B);
  Wire.endTransmission();
  Wire.requestFrom(0b1101000,6);
  while(Wire.available()<6);
  accelx=Wire.read()<<8| Wire.read();
  accely=Wire.read()<<8 | Wire.read();
  accelz=Wire.read()<<8 | Wire.read();
  gforcex=accelx/16384.0;
  gforcey=accely/16384.0;
  gforcez=accelz/16384.0;
}

Comments

Similar projects you might like

Turn your RC Car to Bluetooth RC car

Project tutorial by Prajjwal Nag

  • 11,981 views
  • 1 comment
  • 11 respects

Bluetooth RC Car with Remote Arduino

Project tutorial by Team Windows IoT

  • 41,627 views
  • 3 comments
  • 79 respects

RC Car with Remote Arduino (Without external motor shield)

Project tutorial by 4 developers

  • 8,872 views
  • 0 comments
  • 25 respects

RC Car Over Spektrum Remote

Project showcase by Gkid19

  • 832 views
  • 0 comments
  • 0 respects

RC Car to BT Car Controlled with Blynk

Project tutorial by Team Daxes Hacks

  • 3,598 views
  • 2 comments
  • 6 respects

DIY RC Car

Project showcase by Gyusik Song

  • 4,387 views
  • 0 comments
  • 17 respects
Add projectSign up / Login