Het Patel
Published

RC car

A mobile controlled robotic car built using Arduino Nano, L298N motor driver and HC-05 Bluetooth module.

BeginnerShowcase (no instructions)10 hours16
RC car

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Dual H-Bridge motor drivers L298
SparkFun Dual H-Bridge motor drivers L298
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
DC Motor, 12 V
DC Motor, 12 V
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

RC car

Code

Code

C/C++
char command;

int IN1 = 11;
int IN2 = 10;
int IN3 = 9;
int IN4 = 8;

void stopMotors() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

void setup() {
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);

  stopMotors();

  Serial.begin(9600);
}

void loop() {

  if (Serial.available() > 0) {
    command = Serial.read();
    Serial.println(command);
  }

  if (command == 'F') {
    digitalWrite(IN1, HIGH);
    digitalWrite(IN3, HIGH);
    digitalWrite(IN2, LOW);
    digitalWrite(IN4, LOW);
  }

  else if (command == 'B') {
    digitalWrite(IN2, HIGH);
    digitalWrite(IN4, HIGH);
    digitalWrite(IN1, LOW);
    digitalWrite(IN3, LOW);
  }

  else if (command == 'L') {
    digitalWrite(IN1, LOW);
    digitalWrite(IN2, HIGH);
    digitalWrite(IN3, HIGH);
    digitalWrite(IN4, LOW);
  }

  else if (command == 'R') {
    digitalWrite(IN1, HIGH);
    digitalWrite(IN2, LOW);
    digitalWrite(IN3, LOW);
    digitalWrite(IN4, HIGH);
  }

  else if (command == 'S') {
    stopMotors();
  }

  else {
    stopMotors();
  }

  delay(1);
}

Credits

Het Patel
2 projects • 0 followers

Comments