Jump to content
Electronics-Lab.com Community

Bluetooth controlled car using Arduino


Recommended Posts

IMG_20190804_160822.thumb.jpg.d8a39edf24f55145c6e67adb4e958698.jpgIMG_20190804_160701.thumb.jpg.5b9ef950ff29b5a22553358bcbf1ddd3.jpg

 

I have just started with the youtube channel, so I decided to make a Bluetooth controlled robotic car. As am an electronics engineer I have knowledge about electronics. but I don't know how to build a custom android application. so Before making the project I learn about MIT app inventor and try to make one app which was a great success it is quite easy to do. In this article, we will learn how to make a custom Android application and how to configure the Bluetooth module with Arduino.

Hardware requirements:

  • Arduino Uno
  • Bluetooth HC-05
  • l298n motor Driver
  • acrylic sheet
  • wheels x2
  • geared dc motor x2
  • mini breadboard
  • 4.7k, 2.2k resistor
  • jumper wires
  • 12v battery
  • 9v battery
  • switch

Step 1: Building Chassis

acrylic.thumb.png.76caac079221fa4fc84abfaee14b27ef.png828627102_gluemotor.thumb.png.4cc74bbace837a2e757638b7fbcf3b03.png709859554_allsticked.thumb.png.61b08a57467eb765c7848c6709d6fe36.pngcaster.thumb.png.e4602eb3171b13256c561723653807bc.png

 

I used an acrylic sheet length of 18cm and width of 13cm. First, I positioned all parts that going to be mounted on the chassis. then I used a hot glue gun to stick the parts to acrylic you can use spacers or screws. after mounting all parts I stick the caster wheel at the bottom of the chassis.

Step 2: Connection

1931335297_UntitledSketch_bb.thumb.jpg.3a9bf12d90bac6d740328f6adde59d4d.jpg

Make the connection according to the circuit diagram. we can use separate power for Arduino. Motor driver and 12v battery connected through the switch. As we can see in the circuit diagram there is 2.2k and 4.7 k resistor connected to the pins of the bluetooth module. the main reason for this is the HC-05 Bluetooth module uses a logic level of 3.3v. While transmitting data from HC-05 to Arduino there is no problem because Arduino is capable of receiving data from 3.3v logic, but while receiving any data from Arduino to HC-05 Arduino uses 5v logic which may damage our Bluetooth module, to convert 5v logic level to 3.3v we use a voltage divider method. Make sure that there is common ground between motor driver and Arduino otherwise motor not work.

Step 3: Programming

/*
              Author:DIYelex
              date: 3/8/2019
*/

#include <SoftwareSerial.h> // TX RX software library for bluetooth
SoftwareSerial mySerial(2, 3);  // Connect the TXD pin of BT module to pin 2 of the Arduino and the RXD pin of BT module to pin 3 of Arduino.
int Rightmotor1 = 4; //pin 1 of Rightmotor 
int Rightmotor2 = 5; //pin2 of Rightmotor 
int leftmotor1 = 6;//pin1 of leftmotor 
int leftmotor2 = 7;//pin2 of leftmotor 
int en1=9; //enable pin for Rightmotor 
int en2=10; // enable pin for leftmotor
String readString;
void setup()
{
  pinMode(Rightmotor1,OUTPUT);  // attach Right Motor 1st wire to pin 4
  pinMode(Rightmotor2,OUTPUT); // attach Right Motor 1st wire to pin 5
  pinMode(leftmotor1,OUTPUT);// attach Right Motor 1st wire to pin 6
  pinMode(leftmotor2,OUTPUT);// attach Right Motor 1st wire to pin 7
  pinMode(en1,OUTPUT);  //attach motor drivers rightmotor enable pin to PWM pin 9 of arduino
  pinMode(en2,OUTPUT);//attach motor drivers leftmotor enable pin to PWM pin 10 of arduino
 
  Serial.begin(9600); //Setup usb serial connection to computer
  mySerial.begin(9600);//Setup Bluetooth serial connection to android
}

void loop()
{
  while(mySerial.available()){ 
    delay(50);
    char data = mySerial.read();//store the data come from bluetooth to char data
    readString+=data;
  }

  if(readString.length() > 0) {
    Serial.println(readString); ///Print the data to serial monitor which is given by bluetooth

    if(readString == "Forward"){ //if forward received do following 
      
      digitalWrite(Rightmotor1, HIGH);  ////////////FORWARD ////////////////////////
      digitalWrite(Rightmotor2, LOW);
      digitalWrite(leftmotor1, HIGH);
       digitalWrite(leftmotor2, LOW);
       analogWrite(en1,200);// for controlling speed of Rightmotor vary the value from 0 to 255
       analogWrite(en2,200);// for controlling speed of leftmotor vary the value from 0 to 255
        
     }
    
    if(readString == "Back"){  //if Back received do following 
       
      digitalWrite(Rightmotor1, LOW);  ////////////BACK/////////////////////////////
      digitalWrite(Rightmotor2, HIGH);
      digitalWrite(leftmotor1, LOW);
       digitalWrite(leftmotor2, HIGH);
       analogWrite(en1,200);
       analogWrite(en2,200);
       
     }
    

    if(readString == "Left"){  //if left received do following 
       digitalWrite(Rightmotor1, HIGH);/////////////LEFT////////////////////////////
      digitalWrite(Rightmotor2, LOW);
      digitalWrite(leftmotor1, LOW);
       digitalWrite(leftmotor2, HIGH);
       analogWrite(en1,80);
       analogWrite(en2,80);
       
     }
    

    if(readString == "Right"){   //if Right received do following 
      digitalWrite(Rightmotor1, LOW);/////////////RIGHT////////////////////////
      digitalWrite(Rightmotor2, HIGH);
      digitalWrite(leftmotor1, HIGH);
       digitalWrite(leftmotor2, LOW);
       analogWrite(en1,80);
       analogWrite(en2,80);
       
    }

    if(readString == "Stop"){  //if stop received do following 
      digitalWrite(Rightmotor1, LOW); ///////////stop/////////////////
      digitalWrite(Rightmotor2, LOW);
      digitalWrite(leftmotor1, LOW);
       digitalWrite(leftmotor2, LOW);
       
    }

    readString = "";
  }
}

Step 4: Android App

designer.thumb.png.5849d1595a45b0e5ab9e24e16170d490.pngblocks.thumb.png.9b208ac4f03bd8640e95339d0cd9c3c7.png

 

 

Now we have to build Bluetooth applications that would be capable of controlling your robot car. If you wish to download my application you can download it from github: The Bluetooth car

How I created this application was through App Inventor 2, The images above show both the "Designer" & "Block" view of my application so you can build and change thing up if you wish!

Steps for configuring bluetooth

  • First turn on the switch of robot car
  • Go to setting Click on the Bluetooth
  • TabTurn Bluetooth on Wait for your phone to find the HC-05 Bluetooth module
  • Once it has been found click it and input the password by default it should be either "1234" or "0000"
  • Now open the application Bluetooth car Application and click the " Bluetooth image" button
  • You should see the HC-05 Module (If not re-try the steps above) click on the Module
  • The Application will then return automatically to the main screen and you can see the green text "connected"
  • At this point, the HC-05 Modules Red LED should now be constantly on instead of pulsing meaning a device is currently connected.

Conclusion

Thanks for Reading

watch this project video on youtube

https://youtu.be/iC7P9nyFu9I

 

 

Link to comment
Share on other sites

  • 4 months later...

Music they say is the food for the soul and it is as true a saying as they go. Our tastes may differ but we all do tap our feet and bump our fist in the air when a favourite song of ours is played on the radio or in a restaurant. Are you one among the hundreds who go through the internet to find the perfect pair of headphones for them and yet have no clue what and where to get them. If you are then fear not we’re here to help you with just that. We would not only tell you the best pair of earphones out there under 3000 rupees but also where you can find them.

Music has the power to trigger a range of emotions, but increasingly , researchers have suggested it can also offer some amazing health benefits. Now complement that with a perfect pair of earphones and imagine the effect it would have on your health. We all listen to music while our daily runs at the park imagine being surrounded with nature and having an earphone which has the strongest bass booming in your ears. The picture perfect beginning to a day, isn’t it ? Getting rid of those extra pounds can be made a happy experience with an earphone that would push you to go to the gym and put them on.

ezgif-5-ec95a92ab825.jpg

These my dear readers are the greatest pair of earphones that are in the market now under rupees 3000 ;

  • RAVTEK EXTREME
  • SONY WI C300
  • JBL ENDURANCE RUN BT
  • TAGG INFERNO 2.0
  • SAMSUNG LEVEL U
  • 1MORE IBFREE
  • JBL T110 BT
  • JBL E25 BT
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
  • Create New...