Rafath Bin Zafar
Published

‘Rain1’ RC Car with Arduino

I made this RC car with an Arduino Uno, which I control via an HC-05 Bluetooth module. The project is now in its initial state.

BeginnerWork in progress5 hours21,950
‘Rain1’ RC Car with Arduino

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Female/Female Jumper Wires
Female/Female Jumper Wires
×4
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
L293D Adafruit Motor/Stepper/Servo Shield for Arduino High Quality
×1
DC 3V-6V Dual Axis Gear Reducer Motor
×1
Battery, 3.7 V
Battery, 3.7 V
×1

Software apps and online services

Bluetooth RC Controller

Story

Read more

Schematics

Diagram

Code

Rain1.ino

C/C++
#include <AFMotor.h>
AF_DCMotor motor1(1); 
AF_DCMotor motor2(2); 
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);
char command; 
void setup() 
{       
  Serial.begin(9600);
}

void loop(){
  if(Serial.available() > 0){ 
    command = Serial.read(); 
    Stop(); 
    switch(command){
    case 'F':  
      forward();
      break;
    case 'B':  
       back();
      break;
    case 'L':  
      left();
      break;
    case 'R':
      right();
      break;
    }
  } 
}

void forward()
{
  motor1.setSpeed(255);
  motor1.run(FORWARD);
  motor2.setSpeed(255);
  motor2.run(FORWARD); 
  motor3.setSpeed(255);
  motor3.run(FORWARD); 
  motor4.setSpeed(255);
  motor4.run(FORWARD); 
}

void back()
{
  motor1.setSpeed(255);
  motor1.run(BACKWARD);
  motor2.setSpeed(255);
  motor2.run(BACKWARD);
  motor3.setSpeed(255); 
  motor3.run(BACKWARD);
  motor4.setSpeed(255);
  motor4.run(BACKWARD);
}

void left()
{
  motor1.setSpeed(255);
  motor1.run(BACKWARD);
  motor2.setSpeed(255); 
  motor2.run(BACKWARD);
  motor3.setSpeed(255); 
  motor3.run(FORWARD); 
  motor4.setSpeed(255); 
  motor4.run(FORWARD);
}

void right()
{
  motor1.setSpeed(255);
  motor1.run(FORWARD);
  motor2.setSpeed(255); 
  motor2.run(FORWARD); 
  motor3.setSpeed(255);
  motor3.run(BACKWARD); 
  motor4.setSpeed(255); 
  motor4.run(BACKWARD); 
} 

void Stop()
{
  motor1.setSpeed(0);
  motor1.run(RELEASE);
  motor2.setSpeed(0); 
  motor2.run(RELEASE); 
  motor3.setSpeed(0); 
  motor3.run(RELEASE);
  motor4.setSpeed(0); 
  motor4.run(RELEASE); 
}

Credits

Rafath Bin Zafar

Rafath Bin Zafar

1 project • 2 followers

Comments