유은제gledel
Published

Bluetooth RC Car

Make a bluetooth RC car with arduino by yourself and have a race with your friends!

IntermediateProtip870
Bluetooth RC Car

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Breadboard (generic)
Breadboard (generic)
×1
Bluetooth Low Energy (BLE) Module (Generic)
×1
motor driver
×1
DC motor (generic)
×2
9V battery (generic)
9V battery (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

schemetics of bluetooth control RC car

Code

code of bluetooth rc car

EJS
#define BIA 5
#define BIB 6

#define AIA 9  
#define AIB 10 
 
int carSpeed = 200; 
 
void setup() {
  Serial.begin(9600);   
 
  pinMode(AIA, OUTPUT);
  pinMode(AIB, OUTPUT);
  pinMode(BIA, OUTPUT);
  pinMode(BIB, OUTPUT);
}
 
void loop() {
 
  if (Serial.available()) {
    
    char command = Serial.read(); 
    
    if (command == 'F' || command == 'f') 
      moving_forward();
    }
    else if (command == 'B' || command == 'b') {
      moving_backward();
    }
    else if (command == 'L' || command == 'l') {
      moving_left();
    }
    else if (command == 'R' || command == 'r') {
      moving_right();
    }
    else if (command == 'S' || command == 's') {
      stop_moving();
    }
    else {
      stop_moving();
    }
    
  }
  delay(100);
}
 
void moving_forward() {
  digitalWrite(AIB, HIGH);
  analogWrite(AIA, 255-carSpeed);
 
  digitalWrite(BIB, HIGH);
  analogWrite(BIA, 255-carSpeed);
}
 
void moving_backward() {
  digitalWrite(AIB, LOW);
  analogWrite(AIA, carSpeed);
 
  digitalWrite(BIB, LOW);
  analogWrite(BIA, carSpeed);
}
 
void moving_left() {
  digitalWrite(AIB, HIGH);
  analogWrite(AIA, carSpeed);
 
  digitalWrite(BIB, LOW);
  analogWrite(BIA, carSpeed);
}
 
void moving_right() {
  digitalWrite(AIB, LOW);
  analogWrite(AIA, carSpeed);
 
  digitalWrite(BIB, HIGH);
  analogWrite(BIA, carSpeed);
}
 
void stop_moving() {
  analogWrite(AIA, LOW);
  analogWrite(AIB, LOW);
  digitalWrite(BIA, LOW);
  digitalWrite(BIB, LOW);
}

Credits

유은제

유은제

15 projects • 13 followers
Hello :-) I'm a high school student in South Korea.
gledel

gledel

100 projects • 115 followers
Looking back on my childhood, I was happy when I was making something and I was proud of myself. "Making is instinct!"

Comments