Francesc0
Published © CC BY-NC-SA

Banger BLE Car

An easy Bluetooth controlled toy car.

BeginnerShowcase (no instructions)1.5 hours1,801
Banger BLE Car

Things used in this project

Hardware components

Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
DC motor (generic)
With integrated speed reducer.
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
9V battery (generic)
9V battery (generic)
×1
AA Batteries
AA Batteries
×6
6xAA battery holder
×1
Breadboard (generic)
Breadboard (generic)
Small size
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Marble
×1
Smartphone
×1

Software apps and online services

Arduino Bluetooth Control

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Laser cutter (generic)
Laser cutter (generic)

Story

Read more

Schematics

cattura_(2)_8p49DUXGBY.jpg

Code

banger

Arduino
#include <SoftwareSerial.h>
char data = 0;
void setup() {
  Serial.begin(9600);         //Sets the data rate in bits per second (baud) for serial data transmission

  // Impostazione canale A
  pinMode(2, OUTPUT); // initialize direction pin (motor A)
  pinMode(3, OUTPUT);  // initialize brake pin (motor A)

  // Impostazione canale B
  pinMode(4, OUTPUT); // initialize direction pin (motor B)
  pinMode(5, OUTPUT);  // initialize brake pin (motor B)
}

void loop() {
  if (Serial.available() > 0) // Send data only when you receive data:
  {
    data = Serial.read();      //Read the incoming data and store it into variable data
    Serial.print(data);        //Print Value inside data in Serial monitor
    Serial.print("\n");        //New line
    switch (data) {
      case '1':
        // Motor A
        digitalWrite(2, HIGH);   // set forward direction (motor A)
        digitalWrite(3, LOW);    // disactivate brake pin (motor A)
        analogWrite(6, 255);     // set max speed (motor A)
        // Motor B 
        digitalWrite(4, HIGH);   // set forward direction (motor B)
        digitalWrite(5, LOW);    // disactivate brake pin (motor B)
        analogWrite(9, 255);     //set max speed (motor B)
      case '2':
        // Motor A
        digitalWrite(2, HIGH);  // set forward direction (motor A)
        digitalWrite(3, LOW);   // disactivate brake pin (motor A)
        analogWrite(6, 0);      //set min speed (motor A)
        // Motor B
        digitalWrite(4, LOW);    // set backward direction (motor B)
        digitalWrite(5, LOW);    // disactivate brake pin (motor B)
        analogWrite(9, 0);       //set min speed (motor B)
        break;
      case '3':
        // Motor A
        digitalWrite(2, HIGH);   // set forward direction (motor A)
        digitalWrite(3, LOW);    // disactivate brake pin (motor A)
        analogWrite(6, 255);     //set max speed (motor A)
        // Motor B
        digitalWrite(4, HIGH);   // set forward direction (motor B)
        digitalWrite(5, LOW);    // disactivate brake pin (motor B)  
        analogWrite(9, 127);     //set half speed (motor B)
        break;
      case '4':
        // Motor A
        digitalWrite(2, HIGH);    // set forward direction (motor A)
        digitalWrite(3, LOW);     // disactivate brake pin (motor A)
        analogWrite(6, 127);      //set half speed (motor A)
        // Motor B
        digitalWrite(4, HIGH);   // set forward direction (motor B)
        digitalWrite(5, LOW);    // disactivate brake pin (motor B) 
        analogWrite(9, 255);     //set max speed (motor B)
        break;
    }
  }
}

Credits

Francesc0

Francesc0

0 projects • 0 followers

Comments