"Bonibon" Bluetooth_Controlled_Car
by Azmi Deliaslan in Circuits > Robots
519 Views, 1 Favorites, 0 Comments
"Bonibon" Bluetooth_Controlled_Car
Today, ı wil made a RC Car with arduino UNO and some supplys. You can easly make your RC CAR and have fun. Let's look steps...
PARTS
Here is a list of parts that i used to make this project:
- Arduino UNO
- HC 05 Bluetooth Module
- L298 Motor Driver
- 2*DC Motor
- On/Off Switch
- Jumper Wires (male to male and male to female)
- 9V Battery (i use 10* 1.2V lipo battery)
- Drunk Wheel
SCHEMA
CODE
The code has explanations of code functions. You will easly understand it. If you have a problem , you can contact me.
//satdeliaslan.wordpress.com//
const int in1 = 9; //BACK RIGHT const int in2 = 8; //FORWARD RIGHT const int in3 = 10; //FORWARD LEFT const int in4 = 11; //BACK LEFT
const int enA = 5; //left motor speed const int enB = 6; //right motor speed //!enable pins have to connect with arduino's PWM pins! int yavas=200; //decrease the speed(you can just chance here ,not every code);
void setup() { pinMode(in1, OUTPUT); //all motor pins are output pinMode(in2, OUTPUT); pinMode(in3, OUTPUT); pinMode(in4, OUTPUT);
pinMode(enA, OUTPUT); pinMode(enB, OUTPUT);
Serial.begin(9600); //for serial communication }
void loop() { if(Serial.available()>0){ //if we communicate with hc 05 char durum = Serial.read(); //get the input } //FORWARD if(durum=='w'){ //if we get 'w' analogWrite(enA, 255); //set left the speed(0 to 255) digitalWrite(in1, LOW); digitalWrite(in2,HIGH);
analogWrite(enB, 255); digitalWrite(in3,HIGH); digitalWrite(in4, LOW); } //TURN RIGHT if(durum=='d'){ analogWrite(enA, 255); digitalWrite(in1, LOW); digitalWrite(in2,HIGH);
analogWrite(enB, 255); digitalWrite(in3, LOW); digitalWrite(in4,HIGH); } //TURN LEFT if(durum=='a'){ analogWrite(enA, 255); digitalWrite(in1,HIGH); digitalWrite(in2, LOW);
analogWrite(enB, 255); digitalWrite(in3,HIGH); digitalWrite(in4, LOW); } //BACKWARD if(durum=='s'){ analogWrite(enA, 255); digitalWrite(in1, HIGH); digitalWrite(in2, LOW);
analogWrite(enB, 255); digitalWrite(in3, LOW); digitalWrite(in4,HIGH); } //FORWARD SLOWLY if(durum=='k'){ analogWrite(enA, yavas); digitalWrite(in1, LOW); digitalWrite(in2,HIGH);
analogWrite(enB, yavas); digitalWrite(in3,HIGH); digitalWrite(in4, LOW); } //TURN RIGHT SLOWLY if(durum=='l'){ analogWrite(enA, yavas); digitalWrite(in1, LOW); digitalWrite(in2,HIGH);
analogWrite(enB, yavas); digitalWrite(in3, LOW); digitalWrite(in4,HIGH); } //TURN LEFT SLOWLY if(durum=='m'){ analogWrite(enA, yavas); digitalWrite(in1,HIGH); digitalWrite(in2, LOW);
analogWrite(enB, yavas); digitalWrite(in3,HIGH); digitalWrite(in4, LOW); } //BACKWARD SLOWLY if(durum=='n'){ analogWrite(enA, yavas); digitalWrite(in1, HIGH); digitalWrite(in2, LOW);
analogWrite(enB, yavas); digitalWrite(in3, LOW); digitalWrite(in4,HIGH); } //STOP THE CAR if(durum=='z'){ digitalWrite(in1, HIGH); //if we make HIGH every pin it will stop digitalWrite(in2, HIGH); //or you can do : digitalWrite(in3, HIGH); //analogWrite(enA,0); digitalWrite(in4, HIGH); //analogWrite(enB,0); } }
CONNECTING WITH MOBILE PHONE
I use Arduino Bluetooth Controller for communicate with HC 05 module. You can figure buttons like you want.
Also you can use this application some other projects...Here is the some clues for you: