RC Bluetooth Car

 RC Bluetooth Car     















Components Required:

1)  Arduino Nano 
     Buy Link :- https://amzn.to/4u65iuK

2)  HC-05 Bluetooth 
      Buy Link:- https://amzn.to/3ScDZ4F

3)  L298N motor driver 
      Buy Link:- https://amzn.to/3SdwASE

4)  5v Buzzer 
      Buy Link:- https://amzn.to/436tW3E

5)  5mm LED 
      Buy Link:- https://amzn.to/4udveEZ

6)  Breadboard 
      Buy Link:- https://amzn.to/3PylWoX

7)  Lithium Battery 
      Buy Link:- https://amzn.to/4xj2QEn

8)  Battery Holder 
     Buy Link:- https://amzn.to/4u2vhTX

Connection Diagram:






                       

                           LED Connection 

                                   

                                   LED                 Arduino 

                       +ve (220ohm)             D11

                                       GND              GND 


               


App Control Settings:










Code: 

#include <SoftwareSerial.h>

SoftwareSerial BT(2, 3); // RX, TX

// Motor Pins
#define IN1 4
#define IN2 5
#define IN3 6
#define IN4 7
#define ENA 9
#define ENB 10

// LED and Buzzer
#define LED 11
#define BUZZER A1

char command;
int speedCar = 200;

void setup() {

  Serial.begin(9600);
  BT.begin(9600);

  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);

  pinMode(ENA, OUTPUT);
  pinMode(ENB, OUTPUT);

  pinMode(LED, OUTPUT);
  pinMode(BUZZER, OUTPUT);

  analogWrite(ENA, speedCar);
  analogWrite(ENB, speedCar);

  stopCar();
}

void loop() {

  if (BT.available()) {
    command = BT.read();
    Serial.println(command);

    // Movement
    if (command == 'F') {
      forward();
    }
    else if (command == 'B') {
      backward();
    }
    else if (command == 'L') {
      left();
    }
    else if (command == 'R') {
      right();
    }
    else if (command == 'S') {
      stopCar();
    }

    // LED Control
    else if (command == 'W') {
      digitalWrite(LED, HIGH);
    }
    else if (command == 'w') {
      digitalWrite(LED, LOW);
    }

    // Buzzer Control
    else if (command == 'V') {
      digitalWrite(BUZZER, HIGH);
    }
    else if (command == 'v') {
      digitalWrite(BUZZER, LOW);
    }

    // Speed Control
    else if (command == '0') speedControl(0);
    else if (command == '1') speedControl(25);
    else if (command == '2') speedControl(50);
    else if (command == '3') speedControl(75);
    else if (command == '4') speedControl(100);
    else if (command == '5') speedControl(125);
    else if (command == '6') speedControl(150);
    else if (command == '7') speedControl(175);
    else if (command == '8') speedControl(200);
    else if (command == '9') speedControl(225);
    else if (command == 'q') speedControl(255);
  }
}

// Motor Functions

void forward() {

  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);

  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void backward() {

  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);

  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void left() {

  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);

  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void right() {

  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);

  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void stopCar() {

  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);

  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

void speedControl(int spd) {

  analogWrite(ENA, spd);
  analogWrite(ENB, spd);
}





Please Subscribe my YouTube channel 👇 





Thankyou For Watching...













Comments

Popular posts from this blog

EMO Robot Using Arduino Nano

Obstacle Avoiding Robot Car Arduino Project

4 Best Science Projects For School Without Using Arduino

SENSOR TUTORIAL

ARDUINO TUTORIAL

BASIC SERVO MOTOR TEST

RAIN ALARM PROJECT

AUTOMATIC TOLL GATE PROJECT

Drone Tech | How To Make Mini Drone For Science Exhibition It Can Fly || Remote Control Drone