top of page

Arduino Car controlled by Bluetooth

 

​

Project:

An Arduino Bluetooth RC Car is a remotely controlled vehicle that leverages the versatile Arduino microcontroller platform in conjunction with Bluetooth technology for wireless communication. Here's a brief overview:

Core Component - Arduino Board:  Typically, an Arduino UNO or any other variant serves as the brain of the car. It interprets signals received via Bluetooth and executes actions based on the input.

Bluetooth Module:  Devices like the HC-05 or HC-06 Bluetooth modules are often used. These modules communicate wirelessly with a smartphone or a computer equipped with Bluetooth. When paired with a device, it allows for the remote operation of the RC car.

Motor Control: For movement, the car uses motors. An H-bridge motor driver, such as the L298, is often employed to control the direction and speed of the motors based on signals from the Arduino.

Power Source:  The car is usually powered by rechargeable batteries, such as Li-Ion or Ni-Mh cells. These provide the necessary current to both the motors and the Arduino.

Control Interface:  On the user's end, a custom smartphone application or software on a computer can be used. This interface has controls like forward, reverse, left, right, and stop, which, when pressed, send specific signals via Bluetooth to the car.

Additional Features:  Many enthusiasts add extra features like headlights (using LEDs), horns, or even cameras to their Arduino Bluetooth RC cars for enhanced functionality.

The Arduino Bluetooth RC Car is a blend of robotics, electronics, and programming, offering hobbyists a hands-on experience in building and customizing their remote-controlled vehicles.

​

Parts and Materials:

 

Code for Arduino Bluetooth controlled RC Car:

​

char receivedChar;

void setup() {
  pinMode(13, OUTPUT);   // Left motors forward
  pinMode(12, OUTPUT);   // Left motors reverse
  pinMode(11, OUTPUT);   // Right motors forward
  pinMode(10, OUTPUT);   // Right motors reverse
  pinMode(9, OUTPUT);    // LED
  Serial.begin(9600);
}

void loop() {
  if (Serial.available()) {
    receivedChar = Serial.read();
    Serial.println(receivedChar);
  }

  if (receivedChar == 'F') {  // Move forward (all motors rotate in forward direction)
    digitalWrite(13, HIGH);
    digitalWrite(11, HIGH);
  } 
  else if (receivedChar == 'B') {  // Move reverse (all motors rotate in reverse direction)
    digitalWrite(12, HIGH);
    digitalWrite(10, HIGH);
  } 
  else if (receivedChar == 'L') {  // Turn right (left side motors rotate in forward direction, right side motors don't rotate)
    digitalWrite(11, HIGH);
  } 
  else if (receivedChar == 'R') {  // Turn left (right side motors rotate in forward direction, left side motors don't rotate)
    digitalWrite(13, HIGH);
  } 
  else if (receivedChar == 'W') {  // Turn LED on
    digitalWrite(9, HIGH);
  } 
  else if (receivedChar == 'w') {  // Turn LED off
    digitalWrite(9, LOW);
  } 
  else if (receivedChar == 'S') {  // STOP (all motors stop)
    digitalWrite(13, LOW);
    digitalWrite(12, LOW);
    digitalWrite(11, LOW);
    digitalWrite(10, LOW);
  }
  delay(100);
}

 

Explanation:

​

This Arduino code defines the behavior of a Bluetooth-controlled RC car. Let's break it down piece by piece:

 

Declarations:

char receivedChar;
This declares a character variable receivedChar that will store the command received from the Bluetooth module via serial communication.

​

The setup() function:

​

void setup() {
pinMode(13, OUTPUT);   // Left motors forward
pinMode(12, OUTPUT);   // Left motors reverse
pinMode(11, OUTPUT);   // Right motors forward
pinMode(10, OUTPUT);   // Right motors reverse
pinMode(9, OUTPUT);    // LED
Serial.begin(9600);
}

 

This function is called once when the Arduino board starts.

  • The pinMode function sets pins 13 to 9 as OUTPUTs. These pins are connected to the motors and the LED of the RC car.

  • The Serial.begin(9600); initializes serial communication at a baud rate of 9600.

​

The loop() function:

This function continuously runs in a loop once the setup() function finishes.

​

if (Serial.available()) {
   receivedChar = Serial.read();
   Serial.println(receivedChar);
}

 

This checks if there's data available to read from the serial port. If there is, it reads the next character and assigns it to the receivedChar variable. It then echoes back the received character by printing it to the serial port using Serial.println.

Then, the received character is checked to determine what action should be taken. The action is dictated by turning on/off specific pins based on the character received:

  • 'F': Moves the car forward by turning on both left and right motors in the forward direction.

  • 'B': Moves the car in reverse by turning on both left and right motors in the reverse direction.

  • 'L': Turns the car to the right by only rotating the left side motors in the forward direction.

  • 'R': Turns the car to the left by only rotating the right side motors in the forward direction.

  • 'W': Turns on an LED.

  • 'w': Turns off the LED.

  • 'S': Stops all the motors.

​

delay(100);
 

This creates a delay of 100 milliseconds before the loop runs again. It provides a small pause between reading commands, ensuring that the Arduino doesn't read the commands too rapidly.

​

This code allows the user to control an RC car using Bluetooth. Commands are sent as single characters over serial communication to dictate the movement and behavior of the car.

​

Circuit Diagram:

Project 1_blluetooth car.PNG
bottom of page