DABOD
Published © CC BY

Arduino RC Car with I2C Display!

An Arduino Rc Car but it has LCD i2c for sending messages and debugging.

IntermediateShowcase (no instructions)5,483
Arduino RC Car with I2C Display!

Things used in this project

Story

Read more

Schematics

Schematic

Made using Fritzing

Code

RC Car's Code

Arduino
That's the code guys
#include <LiquidCrystal_I2C.h>

#include "SoftwareSerial.h"// import the serial library\

const int IN1=3;
const int IN2=5;
const int IN3=6;
const int IN4=9;
 int BluetoothData;
 SoftwareSerial HC05(10, 11); // RX, TX
 LiquidCrystal_I2C lcd(0x27, 16, 2);
 int  SPEED_Control=200;
void setup() {
  // fIRST , define the Motor's pin as an OUTPUT
lcd.begin();
lcd.backlight();
pinMode( IN1 ,OUTPUT);// Right Motor 1st wire
pinMode( IN2 ,OUTPUT);// Right Motor 2nd wire
pinMode( IN3 ,OUTPUT);// left Motor 1st wire
pinMode( IN4 ,OUTPUT);// left Motor 2nd wire
 HC05.begin(9600);
 lcd.clear();
 lcd.print("Starting");
}
void FORWARD(int Speed){
  //When we want to let Motor To Rotate clock wise
  // just void this part on the loop section .
  lcd.clear();
  lcd.print("FORWARD");
  analogWrite(IN1,0);
  analogWrite(IN2,Speed);
  analogWrite(IN3,Speed);
  analogWrite(IN4,0);
}
void BACKWARD(int Speed){
  //When we want to let Motor To Rotate Counter clock wise
  // just void this part on the loop section .
  lcd.clear();
  lcd.print("BACKWARD");
  analogWrite(IN1,Speed);
  analogWrite(IN2,0);
  analogWrite(IN3,0);
  analogWrite(IN4,Speed);
}
void LEFT(int Speed){
  //When we want to let Motor To Rotate Counter clock wise
  // just void this part on the loop section .
  lcd.clear();
  lcd.print("LEFT");
  analogWrite(IN1,0);
  analogWrite(IN2,Speed);
  analogWrite(IN3,0);
  analogWrite(IN4,Speed);
}
void RIGHT(int Speed){
  //When we want to let Motor To Rotate Counter clock wise
  // just void this part on the loop section .
  lcd.clear();
  lcd.print("RIGHT");
  analogWrite(IN1,Speed);
  analogWrite(IN2,0);
  analogWrite(IN3,Speed);
  analogWrite(IN4,0);
}

void Stop(){
  //When we want to let Motor To Rotate clock wise
  // just void this part on the loop section .
  analogWrite(IN1,0);
  analogWrite(IN2,0);
  analogWrite(IN3,0);
  analogWrite(IN4,0);
}

void loop() {
 //Rise Up

  if (HC05.available()){
 BluetoothData=HC05.read();
 Serial.println(BluetoothData);
   
  if(BluetoothData=='F'){   // if number 1 pressed .... 
   FORWARD(SPEED_Control);
   }
  if(BluetoothData=='B'){   // if number 1 pressed .... 
  BACKWARD(SPEED_Control);
   }
  if(BluetoothData=='L'){   // if number 1 pressed .... 
  RIGHT(SPEED_Control);
 
   }
  if(BluetoothData=='R'){   // if number 1 pressed ....
   LEFT(SPEED_Control);
   }
    if(BluetoothData=='S'){   // if number 1 pressed ....
  Stop();
   }
   if(BluetoothData=='0'){  SPEED_Control=0 ;}//Speed 
   if(BluetoothData=='1'){  SPEED_Control=50; }//Speed 
   if(BluetoothData=='2'){  SPEED_Control=100; }//Speed 
   if(BluetoothData=='3'){  SPEED_Control=120; }//Speed 
   if(BluetoothData=='4'){  SPEED_Control=140; }//Speed 
   if(BluetoothData=='5'){  SPEED_Control=160; }//Speed 
   if(BluetoothData=='6'){  SPEED_Control=180; }//Speed 
   if(BluetoothData=='7'){  SPEED_Control=200; }//Speed 
   if(BluetoothData=='8'){  SPEED_Control=220; }//Speed 
   if(BluetoothData=='9'){  SPEED_Control=240; }//Speed 
   if(BluetoothData=='q'){  SPEED_Control=255; }//Speed   
  }
}

LCD I2C Library

Credits

DABOD

DABOD

0 projects • 1 follower

Comments