Bluetooth Mini Car

Bluetooth Mini CarCOMPONENTS AND SUPPLIES

NECESSARY TOOLS AND MACHINES

09507 01
Soldering iron (generic)

APPS AND ONLINE SERVICES

ABOUT THIS PROJECT

Its a simple project for beginners that you can do at home, but it cant be your first project because you have to be a little familiar with the Arduino scripting. 
The car is moving by two dc motors and turn by setting one motor forward and the other one backward. 
That's how my car is organised :
Note : Each battery of these is 4v and 700 mAh and its better to put them in series to get a higher voltage.
It's much butter if you solder the cables in the battery and the motors to get the 100% conductivity.
And please if you have any questions don't hesitate to ask.

CODE

Bluetooth 2WD carArduino
This code is compatible with any serial Bluetooth app like "Bluetooth terminal" or you can create your own app using "appinventor.mit.edu" or simply test it with or without bluetooth module using the serial monitor.
char junk;
String inputString="";
long time = 0; 
int state = HIGH;
int frontled = 7;
int frontled2 = 3;
int buzzer = 4;

void setup()                    // run once, when the sketch starts
{
 Serial.begin(9600);     
 pinMode(3, OUTPUT);
 pinMode(buzzer, OUTPUT);
 pinMode(redled, OUTPUT);
 pinMode(redled2, OUTPUT);
 pinMode(12, OUTPUT); 
 pinMode(9, OUTPUT);
 pinMode(13, OUTPUT);
 pinMode(11, OUTPUT); 
 pinMode(8, OUTPUT); 
 pinMode(frontled, OUTPUT);
 pinMode(frontled2, OUTPUT); 
}

void loop()
{
  if(Serial.available()){
  while(Serial.available())
    {
      char inChar = (char)Serial.read(); //read the input
      inputString += inChar; //make a string of the characters coming on  serial
    }
    Serial.println(inputString);
    while (Serial.available() > 0)  
    { 
    junk = Serial.read() ; 
    }      // clear the serial buffer
    if(inputString == "a"){         //in case of 'a' turn the LED on
      if (state == HIGH)
      state = LOW;
    else
      state = HIGH;

    time = millis();    

    digitalWrite(frontled, state);
    digitalWrite(frontled2, state);
    }
    else if(inputString == "f"){   //incase of 'f'= forward
      digitalWrite(12, HIGH); //Establishes forward direction of Channel A
      digitalWrite(9, LOW);   //Disengage the Brake for Channel A
      analogWrite(3, 255);   //Spins the motor on Channel A at full speed
      digitalWrite(13, HIGH); //Establishes forward direction of Channel B
      digitalWrite(8, LOW);   //Disengage the Brake for Channel B
      analogWrite(11, 255);   //Spins the motor on Channel B at full speed
    }
    else if(inputString == "b"){  //incase of 'b'= brakes
      digitalWrite(9, HIGH);  //Engage brakes for channel A
      digitalWrite(8, HIGH);  //Engage brakes for channel A
    }
    else if(inputString == "l"){  //incase of 'l'= left
      digitalWrite(12, HIGH); //Establishes forward direction of Channel A
      digitalWrite(9, LOW);   //Disengage the Brake for Channel A
      analogWrite(3, 100);   //Spins the motor on Channel A at half speed
      digitalWrite(13, LOW); //Establishes backward direction of Channel B
      digitalWrite(8, LOW);   //Disengage the Brake for Channel B
      analogWrite(11, 100);   //Spins the motor on Channel B at half speed
    }
    else if(inputString == "r"){  //incase of 'r'= right
      digitalWrite(12, LOW); //Establishes backward direction of Channel A
      digitalWrite(9, LOW);   //Disengage the Brake for Channel A
      analogWrite(3, 100);   //Spins the motor on Channel A at half speed
      digitalWrite(13, HIGH); //Establishes forward direction of Channel B
      digitalWrite(8, LOW);   //Disengage the Brake for Channel B
      analogWrite(11, 100);   //Spins the motor on Channel B at half speed
    }
    else if(inputString == "w"){   //incase of 'w'= backward
      digitalWrite(12, LOW); //Establishes backward direction of Channel A
      digitalWrite(9, LOW);   //Disengage the Brake for Channel A
      analogWrite(3, 255);   //Spins the motor on Channel A at full speed
      digitalWrite(13, LOW); //Establishes backward direction of Channel B
      digitalWrite(8, LOW);   //Disengage the Brake for Channel B
      analogWrite(11, 255);   //Spins the motor on Channel B at full speed
    }
    inputString = ""; //we clear the variable for the next commande
  }
}

SCHEMATICS

Screenshot%202016-02-21%2019.38.55%20(2).png

Screenshot%202016 02 21%2019.38.55%20(2)

Comments

Popular posts from this blog

How to build a Wall Mounted Family Calendar and Dashboard

built web-app Authentication in React Applications

Secure, Simple and Scalable Video Conferencing with Jitsi