sgaksen
Published © MIT

Arduino bluetoth car

Bluetooth control Arduino car

IntermediateFull instructions provided250
Arduino bluetoth car

Things used in this project

Hardware components

DC Motor, 12 V
DC Motor, 12 V
×4
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
Development Board, Motor Control Shield
Development Board, Motor Control Shield
×1

Software apps and online services

Arduino IDE
Arduino IDE
or
rc car app
Arduino Web Editor
Arduino Web Editor

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Custom parts and enclosures

car_code_NaK4Go6gNV.ino

Schematics

connect bluetoth module

connect motors

Code

Code

C/C++
/*
  Bluetooth car

  written by sanuka 

  rx------->D1
  tx------->D0
  vcc------>+5v
  GND------>GND
*/
#include <AFMotor.h>  //include the library

AF_DCMotor motor1(1); // naming the motors
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);

char val;
void setup() {

  motor1.setSpeed(255);  //give a speed to the motors
  motor2.setSpeed(255);
  motor3.setSpeed(255);
  motor4.setSpeed(255);
  pinMode(13, OUTPUT);

  Serial.begin(9600);

}

void loop() {
  if (Serial.available()) {
    val = Serial.read();
    Serial.println(val);
  }
  if (val == 'F') {
    motor1.run(FORWARD);
    motor2.run(FORWARD);
    motor3.run(FORWARD);//go forward
    motor4.run(FORWARD);
  }
  else if (val == 'B') {
    motor1.run(BACKWARD);
    motor2.run(BACKWARD);
    motor3.run(BACKWARD);//go backward
    motor4.run(BACKWARD);
  }
  else if (val == 'R') {
    motor1.run(FORWARD);
    motor2.run(FORWARD);//go right
    motor3.run(BACKWARD);
    motor4.run(BACKWARD);
  }
  else if (val == 'L') {
    motor1.run(BACKWARD);
    motor2.run(BACKWARD);
    motor3.run(FORWARD);//go left
    motor4.run(FORWARD);
  }
  else if (val == 'S') {
    motor1.run(RELEASE);
    motor2.run(RELEASE);
    motor3.run(RELEASE);//stop
    motor4.run(RELEASE);
  }
  else if (val == '5') {
    motor1.setSpeed(150);
    motor2.setSpeed(150);//change speed
    motor3.setSpeed(150);
    motor4.setSpeed(150);
  }
  else if (val == 'q') {
    motor1.setSpeed(255);
    motor2.setSpeed(255);
    motor3.setSpeed(255);
    motor4.setSpeed(255);
  }
  else if (val == 'V') {
    digitalWrite(13, HIGH);
  }
  else if (val == 'v') {
    digitalWrite(13, LOW);
  }
  delay(100);
}

motor test

C/C++
#include <AFMotor.h>  //include the library

AF_DCMotor motor1(1); // naming the motors
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);


void setup() {

  motor1.setSpeed(255);  //give a speed to the motors
  motor2.setSpeed(255);
  motor3.setSpeed(255);
  motor4.setSpeed(255);
}

void loop() {
  motor1.run(FORWARD);
  motor2.run(FORWARD);
  motor3.run(FORWARD);
  motor4.run(FORWARD);
  delay(1000);
  motor1.run(BACKWARD);
  motor2.run(BACKWARD);
  motor3.run(BACKWARD);
  motor4.run(BACKWARD);
  delay(1000);
  motor1.run(RELEASE);
  motor1.run(RELEASE);
  motor1.run(RELEASE);
  motor1.run(RELEASE);
}

Credits

sgaksen

sgaksen

2 projects • 0 followers

Comments