Arduino – Control 2 DC Motors Via Bluetooth (Perfect To Build a Robot)

In this tutorial I’ll show you how to control 2 DC motors via bluetooth with an Android app created with MIT App Inventor 2. MIT App Inventor is a great platform to get you started with Android development.

In a previous tutorial (click here to see that project), I was controlling 1 DC motor using an app called “BlueTerm”. That app did the job, but it’s not ideal to send constantly different commands in an easy manner.

The app that you’re going to build is perfect to control any Arduino pin or to integrate with your own robot car. You can edit this app for your specific needs.

Bluetooth module HC-05

To establish the bluetooth communication between your smartphone and your Arduino, you need a bluetooth module. This project uses the HC-05 bluetooth module (as shown in the figure below).

Build 25 cool Arduino projects with our course even with no prior experience DOWNLOAD »

Build 25 cool Arduino projects with our course even with no prior experience DOWNLOAD »

This bluetooth module works with serial data. This means that the Arduino sends information and the bluetooth module receives it via serial (and vice-versa).

By default the HC-05 bluetooth module operates at a baud rate of 9600.

Creating your Android app

The Android App will be created using a free web application called MIT App Inventor. MIT App Inventor is a great place to get started with Android development, because it allows you to build simple apps with drag-n-drop.

You need a Google account to sign up for MIT App Inventor and here’s the login page:

Click here to download the .aia file, then watch the video below:

If you go to the Projects tab, you can upload the .aia file for this project

With MIT App Inventor you have 2 main sections: designer and blocks. The designer is what gives you the ability to add buttons, add text, add screens and edit the overall app look.

The blocks sections is what allows to create custom functionality for your app, so when you press the buttons it actually does something with that information.

I recommend that you start by following this project and using the app without modifying it.

If want to make any changes to the app, when you’re done and you want to install the app in your smartphone, go to the Build tab.

Download our Free eBooks and Resources

  • You can either generate a QR code that you can scan with your smartphone and automatically install the app in your smartphone.
  • Or you can download the .apk file, connect your smartphone to your computer and move the .apk file to the phone.

Simply follow the installation wizard to install the app and it’s done!


For this project, you don’t need to install any Arduino libraries. So, you just have to download or copy the following code to your Arduino IDE, and upload it to your Arduino board. Make sure that you have the right Board and COM port selected.

 * created by Rui Santos,
 * Control 2 DC motors with Smartphone via bluetooth
int motor1Pin1 = 3; // pin 2 on L293D IC
int motor1Pin2 = 4; // pin 7 on L293D IC
int enable1Pin = 6; // pin 1 on L293D IC
int motor2Pin1 = 8; // pin 10 on L293D IC
int motor2Pin2 = 9; // pin 15 on L293D IC
int enable2Pin = 11; // pin 9 on L293D IC
int state;
int flag=0;        //makes sure that the serial only prints once the state
int stateStop=0;
void setup() {
    // sets the pins as outputs:
    pinMode(motor1Pin1, OUTPUT);
    pinMode(motor1Pin2, OUTPUT);
    pinMode(enable1Pin, OUTPUT);
    pinMode(motor2Pin1, OUTPUT);
    pinMode(motor2Pin2, OUTPUT);
    pinMode(enable2Pin, OUTPUT);
    // sets enable1Pin and enable2Pin high so that motor can turn on:
    digitalWrite(enable1Pin, HIGH);
    digitalWrite(enable2Pin, HIGH);
    // initialize serial communication at 9600 bits per second:

void loop() {
    //if some date is sent, reads it and saves in state
    if(Serial.available() > 0){     
      state =;   
    // if the state is 'F' the DC motor will go forward
    if (state == 'F') {
        digitalWrite(motor1Pin1, HIGH);
        digitalWrite(motor1Pin2, LOW); 
        digitalWrite(motor2Pin1, LOW);
        digitalWrite(motor2Pin2, HIGH);
        if(flag == 0){
          Serial.println("Go Forward!");
    // if the state is 'R' the motor will turn left
    else if (state == 'R') {
        digitalWrite(motor1Pin1, HIGH); 
        digitalWrite(motor1Pin2, LOW); 
        digitalWrite(motor2Pin1, LOW);
        digitalWrite(motor2Pin2, LOW);
        if(flag == 0){
          Serial.println("Turn LEFT");
    // if the state is 'S' the motor will Stop
    else if (state == 'S' || stateStop == 1) {
        digitalWrite(motor1Pin1, LOW); 
        digitalWrite(motor1Pin2, LOW); 
        digitalWrite(motor2Pin1, LOW);
        digitalWrite(motor2Pin2, LOW);
        if(flag == 0){
    // if the state is 'L' the motor will turn right
    else if (state == 'L') {
        digitalWrite(motor1Pin1, LOW); 
        digitalWrite(motor1Pin2, LOW); 
        digitalWrite(motor2Pin1, LOW);
        digitalWrite(motor2Pin2, HIGH);
        if(flag == 0){
          Serial.println("Turn RIGHT");
    // if the state is 'B' the motor will Reverse
    else if (state == 'B') {
        digitalWrite(motor1Pin1, LOW); 
        digitalWrite(motor1Pin2, HIGH);
        digitalWrite(motor2Pin1, HIGH);
        digitalWrite(motor2Pin2, LOW);
        if(flag == 0){
    //For debugging purpose

View raw code

Note: before uploading the code, make sure you have the TX and RX pins disconnected from the bluetooth module!

Parts Required


You can use the preceding links or go directly to to find all the parts for your projects at the best price!


Follow the schematic diagram in the following figure to wire your circuit.

DC motor Schematics


Launching your app

If you haven’t generated the .apk file in a previous step, you can click here to download the .apk file (which is the Android app installation file). Move that file to your smartphone and open it. Follow the installation wizard to install the app.

Turn on your smartphone’s Bluetooth.

Tap on the newly installed app. Press the “Connect” button to connect your application to your Arduino Bluetooth module.

Now you can easily control the 2 DC motors with your app:

Watch this video demonstration


  • Remove the RX and TX cables when you’re uploading a new sketch to your Arduino board
  • People often connect the TX from the bluetooth module to the TX of the Arduino, that won’t work. Make sure you connect: TX goes to RX and RX goes to TX.
  • If the HC-04/HC-06&HC-05 bluetooth module asks for a password, it’s ’1234′.

Wrapping up

I hope you found this useful.

Do you know a friend that would like to see this project? Make sure you share this project with your friend!

Do you want to learn more about building apps for Arduino? Get access to our course: Android Apps for Arduino with MIT App Inventor 2.

Thanks for reading,


P.S. If you don’t have a bluetooth module, read my HC-05 review here.

Learn how to program and build projects with the ESP32 and ESP8266 using MicroPython firmware DOWNLOAD »

Learn how to program and build projects with the ESP32 and ESP8266 using MicroPython firmware DOWNLOAD »

Enjoyed this project? Stay updated by subscribing our weekly newsletter!

343 thoughts on “Arduino – Control 2 DC Motors Via Bluetooth (Perfect To Build a Robot)”

  1. i already did it for my sumobot project… but i get the idea from your previous video that control one dc motor.. and i’m really thankful to to this site… may i ask you if the android app that you use in this video is your own code..?

    • Thanks for trying my projects!
      Yes this Android app was created by me using MIT App Inventor.
      your can download all my source code for free. (just click share and a download link will unlock)
      (I know we already talked through facebook, but I want to reply also through my blog! : ) )

  2. Hi my friend!

    I had a problem in this proyect… when a charge the code, in the botton it says “avrdude: stk500_getsync(): not in sync: resp=0x00”

    And one motor star to move without pressing “1” or “2”, etc…
    What could probably be?

    • Hey Henry! Thanks for stopping by and try my project!

      Just two quick questions.
      Are you using the exact same parts as me? (and you followed my exact schematics?)
      which version of the Arduino IDE you’re using?

      The DC motors should only be moving after you pressed some buttons.

      (before even connecting your Bluetooth module)
      First try to control the DC motors with the serial monitor by sending ‘1’, ‘2’, etc . And they should be working just fine.

      Please let me know if it’s working!

  3. hi rui… i want try this tutorial. but do u have full source code app in android ? and what apps to use that’s apps? ECLIPSE ? or ANDROID STUIDO ? .


    • Hi! Thanks for taking the time to leave a comment!
      Yes you can definitely do that!
      I recommend you to use the IC because it’s easier and It looks more “clean”
      But if you prefer to use a Dual H-Bridge it will work exactly the same!

      Let me know if this helped you.
      Good luck with your project,
      Rui Santos

  4. hi rui

    can i use Bluetooth Serial Module (HC-05 Master/Slave mode) in this project ? becuse i’m not sure this module have 6 pin.

    thank you so much :’D

  5. Hi Rui

    just to let you know. Ive Powered my HC-07 Module with 3.3v and without using voltage divider for the output of the arduino. it worked well for 5 min only. then the HC-07 STOP working. i think the my bluetooth module has burnt or damaged permanently :(.

    im thinking to use Order LC-05 to try it. What do you think

  6. HI Rui
    I’ve got a question, does your arduino code just works with the hc-05 bluetooth module or I can use another one like the hc-06 ,this one has 4 pins?

    Thanks a lot for the tutorial

    • Hi David,
      thanks for taking the time to watch my tutorials.
      I think by default it will work.
      They are exactly the same. but the HC-05 has some pins, and the HC-06 you need to solder wires.
      But they work the same.
      Good luck with your project,
      Rui Santos

    • Hi John.
      Thanks for your feedback!
      you can find that IC in almost any electronics store.
      I would prefer to buy this shield below.
      This has 2 IC’s (L293D) you can either use it with your Arduino. there are some libraries to work with this shield.
      Or simply remove the IC and use in your project!

      Arduino DC Motor Shield:

      5 IC’s – L293D

      Good Luck with your Projects,
      Rui Santos

  7. hola soy de chile y me encanto tu tutorial el problema es que no me deja bajar la aplicación desde mi teléfono… como lo puedo instalar?

    • Hi,
      I don’t speak Spanish. but I know Portuguese. So I understood what you said.
      My app is available to download here:
      Simply enter your email and you’ll receive a secret download page with all my projects.

      Or you can simply click the like button and the code will unlock.

      thanks for stopping by!

    • Hi Andi.
      For what I’ve heard that LC-05 Bluetooth module works with my project.
      I’ve not tried it myself but it should work.
      the password and bluetooth configurations might be different.

      The programming is done in the Arduino.
      you don’t need to programm the Arduino Module.

      Thanks for taking the time to read my projects!

  8. Hi Rui

    I wanna ask you something more about the password, when i pair the bluetooth modul they ask about pass but stil not work to connected. The bluetooth module dont ask about the pass. What i must to do?


    • Hi Andi.
      First go to your bluetooth settings and pair your smartphone with the Bluetooth module.
      (Use the password ‘1234’ or ‘0000’.)
      As soon as it’s paired. Go to the ArdBlue app and click: “Choose device to connect to” and choose your bluetooth module.

      I hope this solves your questions.
      Rui Santos

  9. Hi RuiSantos,

    I have got a problem when I tried to set up the hardware of what you introduced above; however, I found out that there were signals of int1 and int4 were locked to turn on the LED light and one of motors was continuously running forward only (another one was stopped) when I used generic motors to connect L298 development board module, which was connected to Arduino Uno development board. I could not control pinint1 to pinint4 by using your Skretch programme.

    I tried not to supply power to motor and only run your sktech program to send signal to control pinint1 to pinint4 of L298, it was successful for me to see the response of the MCU controling normal.

    Could you tell me what wrong with my hardware setting? Does noise come from the motor since the ground is commonly connected between L298 and Arduino Uno?
    How can I solve this problem please?

    Best regards,


    • Can you tell me exactly which motor board are you using?
      (Send me a link with the information)

      You’re debugging all your code using the Arduino IDE? right?

      which DC motors are you using?

      • Hi Rui,

        I fixed the problem already since being careless of matching pins between Atmega328 and L293D. I am using motor drive of L293D of Sparkle Brand to connect Arduino Uno. Thank you for your reply.

  10. Hi Rui,

    I am urgent to know your opinion for the problem solving since this will become reference for my college project please. Thanks you very much.


  11. Hi Rui,

    I am urgent to need knowing your opinion since I will take your tutorial case as a example for my owned project. Could you reply me as soon as possible please?



    • Boas Daniel,

      Sim a ideia por de trás do programa é o mesmo,
      só tens que mudar o código do Arduino e em vez de controlares um DC motor é um stepper motor.
      Tenta procurar um exemplo de Arduino com stepper motors para teres mais umas ideias!


  12. Hai Rui,

    i have a problem with this arduino. My dc motor can run if i connect with my laptop (usb) but with 9v battery cannot run. Blueterm not response if i enter numbers with 9v battery, but with usb, the blueterm is completely response and my dc motor run (left, right, off). Why?

    • Hi, thanks for trying my projects..
      The problem is simple.
      The 9V battery don’t have enough current for your circuit, you will need another type of battery that can handle more current.

      The bluetooth module and DC motors takes to much current from the 9V battery

    • Hi, thanks for trying my projects..
      The problem is simple.
      The 9V battery don’t have enough current for your circuit, you will need another type of battery that can handle more current.

      The bluetooth module and DC motors takes to much current from the 9V battery.

    • Hi,
      thanks for your feedback.
      That question requires almost an entire tutorial.
      What I can tell you right now is that it works like it does with the Arduino… The bluetooth module will establish a communication via the TX and RX pins.
      and your smartphone will establish a communication with the bluetooth module.

      It will also depend in which PIC you’ll be using. you need to read the datasheet…

  13. it possible to power up arduino like in your project with 18v dc supply (2 9v dc battery connected in series)??since it doesnt work in 9v dc supply??and what can you advice to me to power up my bluetooth controlled robot..
    thanks morepower..

    • Don’t do that… That’s not a good idea. Too much current probably.
      One way to do that is using AA batteries with some battery holder.

      The best way is to get a LiPo rechargeable battery for the Arduino.
      Here are some that might be good for your project:

      before you buy anything make sure you get the right for your motors too.
      the problem with the 9V batteries is that they don’t have much current. It’s better to use AA batteries in series 🙂

      I hope this helps bryle!
      Have a nice day,

      • Hi, Thanks you for your remind. Yes, it may be lack of current for 9Vlot battery. In adddition, I had use your Android app and would like to add on new things on it. However, I do not how to open your attahced files such as .src and project.perproties Could you tell me how I can open your generic Android app source code in App Inventor please? I know that I have to use App Inventor on MIT wedsite, is there an off-line App Inventor for me to run the changing of the source code on Window platform please?

        • hi Peter, I’m almost sure it’s lack of current… that’s the problem with 9V batteries…

          I’ve made a video using MIT app inventor.
          It runs on the browser and windows at the same time.
          (You create the screen and look of your app on the browser. The functions, what your app actually does is programmed with a windows application.)

          Please watch the video on that post where I explain everything. Let me know if you have any questions!


  14. thanks a lot rui..for helping..
    im kind of confious sir ,about the IC of L293D..cause there’s another one IC the L293DNE??you think it really matters if i use the L293DNE IC..thanks for helping sir

    • Hi Bryle,
      I’m glad I could help.
      Some IC’s have different versions, the L293D as some variations just like the L293DNE.
      I just took a quick look and they seem to work exactly the same.
      But before you test anything check both IC’s datasheets and compare the pins Inputs and Outputs and voltages.

  15. Hi Rui,
    Could you tell me which development platform for me to edit soruce code for BlueArd please? Is it Eplice or Oracle Java Development Platform?
    Since I would like to edit source code for BlueArd, could you share with me whether there is an off-line App Inventor application software to use? Sometimes I can’t do interface development by online-MIT App Inventor. Thanks

    • Hi Peter,
      When you download that .zip folder it comes with 3 files.

      Arduino Sketch
      BlueArd Source files (for editing purpose)

      The BlueArd.apk is the app installation file.
      If you want to edit the app simply upload the BlueArd Source files into MIT APP Inventor.

      You need to be online to use MIT App Inventor…

      • Hi Rui,

        Thank you for your answer; howver, is it possible for me to edit the source code of the app by using off-line App Inventor or other opensource freeware please?

        In addition, I’ve got another problem that I could contorl turn left and right of the mobile robot using Android cell phone; but the robot could not be morved forward and backward, somethimes left wheel was moving meanwhile right wheel was not moving in parallel speed. I wonder whether the circuit power could not supply to motors via L293D since I am using 9 Vltage battery to supply power the whole MCU control circuit board and L293D.
        My tutor told me that it shall be supplied of power to motors vis L293D independently.
        Could you share with me your opinion please?
        Many thanks.

      • Hi Rui,

        I had followed your suggestion to open BlueArd project source code, but the online program prompted me error since your file is not .aia file.
        I could not attach the print screen for your reference; would you advise where I can download your a completed update projecy source codes please?

        • yup you’re right my source files no longer work with MIT app Inventor…
          They updated their entire website.
          I need to create everything again from scratch…
          Right now I don’t have the time do that… in 2 weeks or something I’ll create a new source code.

          Sorry. They erased all my projects that I thought were saved :S

          • Hi Rui,

            Yes. MIT App Inventor updated to version 2; but finally I could find out the old version to edit your soure codes. Many thanks.

  16. Hey,
    I am using a single 9v battery and following your tutorial exactly. Also I am using 2 12v dc motors (60rpm). Is the 9v battery suuficient to run the motors? If not, what alternative can i use?

    • Hi Piyush,
      No… the 9V battery won’t be able to handle that.

      I would recommend you to get some Lipo rechargeable batteries for your project!

  17. Hey Rui,
    I purchased an hc 05.. but it has 6 pins.. There are 2 voltage pins.. 5v and 3.3v.. Which pin should i connect to my arduino..also do i need a voltage divider to connect my hc 05 rx tx pins to arduino?

  18. Hi sir rui thanks again for helping..sir can you help me where to put voltage divider and how to make voltage divider?like providing me schematics that i can easily understand cause im a newbie in arduino and also to electronics..please help me sir..merry christmas sir

  19. hello friend have a doubt everything works but the part where you press STOP, FORWARD and BACKWARD not work, only works for the left and right and not to do, please a solution, I did all the step to the tutorial is not wrong if the APP
    arduino or codes.
    please help me is for my final semester project please.
    congratulations and greetings from grasias por conpartir PERU 2014 and happy new year hope your prompt help.

    • Hi Kishuko.
      Thanks for trying my project!

      Does the stop, forward, backward commands work when you’re testing you’re project using only the Arduino Serial monitor?

      Happy new year,

    • Hi Bryle,
      Please first read the update on top of this page.
      then you need to download the source code provided.

      it include a .zip folder with 3 files inside.
      Unzip it and you need to upload the BlueArd Source files into App inventor.

  20. Rui,

    Thanks for this great tutorial. I have downloaded your source code and have it setup. I am hoping to add in some buttons for lights and other functions, but was wondering how you figured out which byte number to send to correspond to the arduino pin. Button1 (GO!) = 49, which drives motors forward.

    I’m happy to send you the code when I have it implemented.


      • How did you figure out which byte number to send to correspond to the arduino pin. Example: Button1 (GO!) = 49, which drives motors forward from a pin.

        If I wanted to turn on a light using digital input 8, what byte would I send?

        • That byte has nothing to do with the Arduino digital pins…
          if you want to turn on a light using the digital pin 8 you can create an if statement for example.
          if(state==’0′ ){

          and the Android app would send a 49 to the arduino via bluetooth.
          if you want to turn off for instance you can do this.

          The Android app will send a 50 via bluetooth.

          this is just an example you can send any values you want and you arduino code can do whatever you want.
          I hope this helps,

          P.S. Please download all my code, upload it to the App Inventor (read the update at the top of the page) and you’ll see how it works 🙂

  21. Hey Rui,
    I am following your project and using 2 12v DC motors. I am making an independent robot so won’t be providing power through USB. I am thinking of providing external power supply to Vc pin of l293d which provide power for the motors only instead of directly connecting it with the 5v pin of arduino. So what do you suggest as a power supply for arduino and power supply for the motors separately?

    • Hi Simon,
      As you said you need an external power supply.
      If it’s to control something that need to be in movement like a robot.
      I would get a Lipo rechargeable battery to power up those motors.

      Otherwise just find a 12V wall chart power supply
      I hope this helps

  22. gudeve sir rui..
    what exact current do i need to run the motor like a robot??
    i tried to connect the motor on a four 1.5v battery, and 9v battery for arduino and bluetooth runs, but when i tested it on ground the motor seems cannot handle the load..please help..godbless sir

    • You need to read the datasheet from your DC motor…
      and see how much voltage and current it needs to work properly.
      Then search for the right battery for that…

  23. hi rui, first of all great project man….but there is a problem with BLUEARD… shows an error….. “Need BLUETOOTH_ADMIN permission: neither user 10115 nor current process has android.permission BLUETOOTH_ADMIN”

  24. j’ai un module JY-MCU Bluetooth Wireless Serial Port Module for Arduino que je l’ai acheté de ce site: et je veux savoir est qu’il marche ou pas ainsi s’il vous plait vous pouvez m’envoyer le code source sur mon mail:

  25. which platform u r using to create apk file….even im using ecllipse
    i downloaded ur apk files but how can i edit those files…pls guide me throgh out this project plzzz….and send me the coding for arduino

  26. hi rui i need ur assistance through out my project so pls help me….i want make an car controlled over bluetooth using android app….so send me details about it
    and which platform u r using to create android app…im using eclipse…and send the details of everypart that needs to tis project…thank you

  27. hey rui
    i want screen shot of appiinventor bluetooth connection designer block……
    and i want to learn how to creat app in app inventor ….

  28. Dear Random Archive BlueArd Source (for editing purpose), I can not open from the MIT App Inventor please point me how I can edit?

    • The source for this project can only be edited with MIT App inventor Classic version.
      It won’t open with AI2.
      (Please read the top of this page and you’ll understand where you need to go)

      Thanks for trying my project!

  29. Hi Rui Santos,
    I have a question, why pin Vcc Bluetooth HC-05 has been given 5V DC from pin 5V DC Arduino (as a reference datasheet Bluetooth HC-05 max 3.3V) ? It could be damage, isn’t it?
    Thanks for your explain.

  30. Hi, I am creating a app used in bluetooth control wheelchair via arduino in my project. Your design inspire me a lot, thank you!
    However, I have a problem, I downloaded your source which used in app inventor and arduino code.When I ran it, the app said my android phone was connected bluetooth with arduino but it had no response when I clicked the button on my phone. The strange thing is that it responses correctly when I enter signal by serial monitor like “1”,”2″,”3″. I can’t find out the problem, do you have any idea?

    • Did you connect the TX from the bluetooth Module to the RX of the Arduino? (and vice versa)

      Can you elaborate a bit more otherwise it can be a compatibility problem with your smartphone…

  31. Thank you man i have a final year project it’s a smart home. your tutorial will help me a lot thanx again

    From Afghanistan

    • Hi jezreel,
      I’ve only tested this project with this bluetooth module.
      If you already have a different one you should try.
      This project should work just fine with any bluetooth module, because all of them establish a serial communication with the Arduino.

      Have a nice day,

  32. Nice app U got there! I have one dc motor to control! that should be a problem! i would love to change your app so there were 4 buttons !2 of them just the way it is – on a push it sends a comand but 2 of them would be working like so – when i push it and hold it – it would send letter A to arduino and on a release it would send lower case coreseponding comand letter , in this case a! and for other button B,b! BUT THERE IS ONE PROBLEM – i don`t know how to make such a button witch works on touch and release….

    • Thanks Kaspras,
      I’m glad you found my app useful.

      I recommend you to test my project first and see if it’s working for you.
      Then open my app with MIT App inventor and start getting familiar with the programming environment.
      It’s pretty easy to do what you’re looking for.
      They have pre-built in functions to trigger actions On click buttons for example.

      Have a nice day,

  33. Still can`t find a way to edit a button to make it work like i need to….on a push it would send a capital A and on a release it would send lower case letter a !

  34. Changed to my needs your app… except i can`t find info on how to create a button witch sends on comand when i press the button and hold but then when i release it sends another. like rc car control button

  35. Hi,
    does this bluetooth module HC-06 works correctly with this project?
    The link is here

  36. How to seperate those 2 comands – i`ve added them but i need that seperation…PLEASE take a look and try to explain to this dum man what he need to do to make this finaly work…
    Would even these comands go to arduino serial like when i send them trough arduino serial monitor?

    • I don’t have the time to make the code for everyone who asks me sorry.
      There’s simply not enough time in the day to do that.
      I already told you you can use the long click function to do that.
      and you can use a NOT logic block for example to see when you stop pressing the buttons.

      I guess you can change most of the arduino code to do exactly that. and don’t worry so much with the app.

      Sorry for not being able to help you much more than this.
      Have a nice day,

  37. Hallo Rui,

    first of all thank you for your awesome description!!
    I had made some more buttons in the App and build some LEDs that can show the way, but now i don’t know how to set my arduino that the motors only run when i press the bottons on the app without using a stop botton…

    Do you know a way to to this?

    Thanks a lot

    • Hi Stefan,
      Please read some of the comments above.
      I think that can be accomplished with the LongClick feature of the buttons.
      and the change the arduino code to be able to do that.

      Thanks for asking,

  38. Sir when i m trying to connect with HC05 module with my phone using blueArd app then it showing…

    Runtime error
    Need BLUETOOTH_ADMIN permission:Niether user 10113 nor currentprocess has android permission. BLUETOOTH_ADMIN

    pls sort out my issue.

    its paired and working good with serial monitor.but not working with app blueArd(not connecting actually).sor out plz

    • Can you try this project with another smartphone?
      It might be a compatibility problem with yours i guess.
      Or you have to root your android…

  39. Hi Rui
    How to change the baud rate of the bluetooth module? Mine (HC-06) has default baud rate of 38400. I want to change it to 9600, need you valuable advice.
    Thanks in anticipation…

  40. hey there
    awesome work bro!
    just wanna ask one thing if I want to activate an alarm whenever I stop the motors, does it possible with extra components and if yes please help me!

    • Yes,
      That’s something you can easily do.
      Open my arduino code provided-
      Simply add a new OUTPUT in the Arduino (a new digital pin). That way you can control some type of buzzer.
      Then in the “if” statement related to the “STOP” button
      Simply activate that buzzer everytime it’s pressed the button

      I hope this helps!

  41. Hi Rui Santos
    I want to use the captor LM35 in the program but i didn’t found his library , can you help me please!!thanks for anticipation .

    • Hi Ayoub,
      Can you send me a link for the part you want a library?
      And I’ll see if I can’t find.
      Have a nice day,

  42. Hi, currently I’m working on this similar project but controlling the mobile robot through the accelerometer sensor. Now, I’m facing problem on my Bluetooth connection. I successfully pairing both my android and arduino uno. On the serial monitor it shows the data but my DC motor is not rotate. I dont know why. Do I need to setup or configure anything with the Bluetooth module?? This is my first time using arduino with bluetooth connection and I’m really noob. Help me pls..

    AS for this project, I’m using:

    1.Arduino Uno
    2.Cytron Bluetooth Module ( + XBee Shield (

    • Hi!
      What app are you using?
      have you started making the code for the accelerometer?
      If you’re trying to use the bluetooth project for the first time.
      I recommend you to test my project first as an example and see if it works for you.
      Then later start creating your own projects.

      I hope this helps,
      Rui Santos

      • Thanks for reply Mr. Rui Santos,

        At the moment I develop my own apps using MIT App Inventor..In fact, I also try to use the available apps by downloading them..sadly both of the apps didn’t work. What do you mean code for accelerometer? Is it the arduino code or the apps code?

  43. hi
    im doing the project control of dc motors using smart phone
    i can control the motors by serial monitor.but not work on my smart phone.(using galaxy duos)
    please help

  44. Hello!
    could you help to build an app like that by sharing the screen shots of “DESIGNER” AND “BLOCK”?

  45. Hey Rui Thanks for the awesome tutorial..

    I am trying to implement the same project using the same parts and arduino duemilanove now the problem is i am able to control the motors via the serial monitor of the ide but not via Bluetooth neither app or blueterm. I have tested the bluetoth module for communication via the led blink example.
    also when i input commands via the serial monitor the commands motor left , right etc appear on the blueterm on my mobile but not being able to enter anything on the mobile

    • Hi Zeon,
      Have you tried all the steps I tell you on the tips?
      Are the bluetooth cables connected to the Arduino properly?
      TX from the Arduino goes to the RX of the Bluetooth module, etc…

  46. If I remove Arduino’s Atmega328 IC and build the same circuitry on the breadboard by using 16MHz crystal and other components (that we can use to make arduino uno on breadboard)?

  47. f I remove Arduino’s Atmega328 IC and build the same circuitry on the breadboard by using 16MHz crystal and other components (that we can use to make arduino uno on breadboard)the would program or sketch uploaded on it work?

    • yeah It will work just fine Pritesh.
      You can find plenty of information if you search on the web for something like, Arduino on a breadboard.

  48. Boas Rui , é o seguinte eu fiz a ligação certa como metes-te ai mas quando ligo o arduino ao computador para alimentar o arduino começa a fazer um barulho sabes como resolve-lo ?

  49. Hey Rui !!!
    This is my error : “Runtime Error : need BLUETOOTH_ADMIN permission”.
    I think it may be in your BlueArd.
    Can you help me ???
    What is problems??
    Tks .

    • Hi Taichi,
      that’s a problem with your bluetooth setting. that never happened to me though.
      so make sure you go through all the bluetooth settings and enable all the permissions

    • Hi Tamojit.
      Using my app and if you change the arduino code to work similar to that vido you sent me you can control the speed of your DC motor just fine 🙂

  50. Hi Rui,

    I’m trying to add a couple more buttons to the app that you built for the motor control. I’m controlling three different motors (each with different drivers) and I need two more buttons to control forward and backward movement. I’ve got two motors working like a charm, no problem. The issue that I’m running into is that I don’t know what “number” to assign for the bluetoothclient byte to send to the android. I figured it would just continue on from the previous ones, 54…55…56, but that didn’t work.

    Can you help me?

    • Hi Zsolt,
      If you read this tutorial:
      You can combine my project with that tutorial and control your the DC motor with the shield.

      I hope this helps,

  51. Do you mind if I quote a couple of your articles as long as I
    provide credit and sources back to your weblog?
    My website is in the very same niche as yours and my visitors would certainly benefit from
    a lot of the information you present here. Please let me know if this alright with you.

    Many thanks!

  52. Hi, Rui Santos
    this is my first write to you, I am working on “LED On-Off application” this is very simple application.I am using HC-05 bluetooth module, arduino UNO and Android development tools like Eclipse.
    I have tried lots of android application but does not work for me.
    can you please help me in developing a simple LED on-off two button application in android.
    I have tried below application
    but it get crashed on pressing “On button”

    • Hi Lalit,
      Unfortunately I don’t work with android development so I can’t help you much…
      I’ve just created a few simple apps with MIT App Inventor and that’s all…

      Have a nice day,

  53. Hi,
    Excellent Work!!!!!!!
    But can’t find this BLUEARD App, so can u please help me with the download of BLUEARD app.

      • Thank You!!!!!!!!!!!!! For sharing this Page.
        Actually we are doing you’re project as a Mini Project
        in our institute. We really liked this….. Its a great website created by you, helping young engineers.
        We may need your help in future too, so your cooperation will be highly appreciated by my friends and me

        thanks again!!!!!!!!!!!!!!!!!!

  54. Ola, estou a tentar fazer este projecto mas infelizmente não funciona.
    Quando carrego num botão na app, o arduino parece receber a informação mas os motores não andam… tenho o HC-07 e o linvor, qual o melhor?
    qual será o problema?

    • Olá Cintia,
      Qualquer modulo de bluetooth que funcione por comunicaçao serial deve funcionar bem com o meu projeto.
      Um dos problemas comuns poder ser que o seu modulo de bluetooth venha mal configurado/ou com outra configuraçao por defeito.

      Para este projeto funcionar com o arduino tem que configurar a baud rate do modulo de bluetooth para 9600

  55. hi rui santos
    firstly i would like to thank u for sharing your experiences and project idea’s in web
    and i have done this project and it is working perfectly fine, and now i’m willing to add few more buttons to that app so that i can perform few more tasks, can u please send that .aia file of 2 dc motor control to me so that i can improve this project little.

    once again thank u

  56. Hi Rui, if is to add in 2 limit switch between the motor to let it toggle forward and reverse, is it possible?

  57. hi Rui..i already try your project.i got this problem..the motor wont rotate when i press 2.. but it functioning well when im press 1 or 0..can you help me.

    • Hi wann,
      Are you sure the L293D IC is well wired?
      Please follow my exact schematics. If those commands are working, all the others should be working too…

  58. hi.. i have problem with the motor. the motor cannot function well. only one motor can rotate at one time. i use bluetooth spp and bluebee. is it effect the circuit??

    • This project works with the Leonardo.
      But the serial communication with the Leonardo is a bit different. So You need to change my arduino code to receive the data properly via serial

  59. Hi! Thanks for these awesome tutorials!! When I try to connect my phone to Bluetooth it cannot find any nearby Bluetooth devices to connect to. Do you know what the problem is?

        • It might be, I’m not sure though.
          It should work just fine… Read the feedback from the seller from where you bought the item.,,
          Otherwise if you follow my exact steps it should work just fine.
          Please read carefully my tips on this blog post

  60. Ok this time I redid the circuit using your,single DC motor tutorial. I connect via blueterm and it actually worked! But then I got more problems. It would disconnect and I would have to reconnect. Then it would say it was connected but when I tried to send a command it would disconnect again. Now it won’t connect at all.
    The company is sending me a new one since they actually sent me the wrong one that had six pins instead of four. It should still work though, even with six. So for now I’ll just assume it’s defective and wait for my new one. I hope it at least works.
    Thanks for the great tutorials!

  61. Hey how would I send a command that only makes the DC motor turn on for 10 seconds then turn off? I’ve tried several methods but none seem to work. Thanks!

  62. thanks for the tutorial but can you please tell me what changes do i need to make so it would go forword as long as i press the botton on my mobile?

    • Hi Alex,
      I don’t think that works with MIT App Inventor.
      I know MIT app inventor has a long button click feature… but I’m not sure if it would work as I’ve never tested myself

    • Hi Liviu,
      I think that shield has a few project examples or it probably comes with a custom library,
      Compare their project examples with my code.
      You might need to add their library and just change a couple of lines from my code where I control the DC motor.
      But my bluetooth app will work just fine with your shield

  63. I just like the valuable info you provide for
    your articles. I’ll bookmark your blog and test again right here frequently.
    I am rather certain I’ll be informed many new stuff right here!

    Best of luck for the next!

  64. sir can you help me with my project . . .i want to add a water sprinkler to your project . . . when i click “GO!” the sprinkler will turn on . . and stop after a few seconds . . .

  65. When I connected the Arduino TX cable to bluetooth TX and the Arduino RX to bluetooth RX, on the serial monitor numbers 1,2,3,4,5 work fine. But when I connected the Arduino TX cable to bluetooth RX and the Arduino RX to bluetooth TX, on the serial monitor numbers 1,2,3,4,5 don’t work. Why?

    • Hi Zsolt,
      That’s impossible, unless the pins are labeled incorrectly.
      The Arduino transmits information with the pin TX and the bluetoth module receives that information with the RX pin. (And vice-versA)

      • Ruis master why his software can not be used when connected to bluetooth hc-05?
        whether the application program of android is wrong ..?

        • Sorry Doni, I didn’t understand your question, what do you mean?
          (If you want to upload the code into your arduino, you can have your bluetooth module connected to your arduino, because the Arduino needs to have the RX pins available so it can receive the code you are uploading with your computer)

  66. Hi Rui,
    On the serial monitor numbers 1,2,3,4,5 work fine as your description. I can connected the phone to bluetooth, but with the phone I couldn’t control motors.
    What can be the problem?

    Thanks your help!

  67. Hi Rui,
    Your application did help me a lot in my project, however, I want to change it a little bit. I want my application to send the ASCI value as long as the button is pressed and when the button is released it would stop sending the value, I want to control my robot with that application but without a stop button, well I am a little new to the android programming and I need your little help to do that. Can you help? Thanks in Advance.

  68. i make all the connections well and when i send “1””2″ecc. from the serialmonitor the motors works but when i try to control them from bluetooth don’t happen anything what i’m doing wrong?

  69. Hi rui,

    I have one problem to modify your android app.
    I download all those codes which you was given. How to modify when i extract the files it came an APK file, arduino sketch and source code for APK. Where can i use that apk source code to modify your android app with my convenience.

  70. Hi Rui,
    I tried this project today and it worked well. Why is it that when I connect the motor pins directly to arduino pins, the motor won’t work but after using a motor driver IC, it works fine. Where does the current required come from even when no other external power supply is used?
    Also, I need the motor to turn off after 5 sec of operation. I tried”delay(5000);” but that has not solved the problem. Any bright ideas.

    Thanks 🙂

  71. hello rui,
    as i watched your video controlling the 2 motors …
    wen you gave go (forward) command both the motors started spinning ..
    i want to use this for a rc car which will work on bluetooth…
    so if both motors spin wen i give forward command the car wont go as i want…

    so please help me out of this …!!
    if u can please message me on “” it would be nice.

    thank you

  72. i m using arduino duemilanove s/n 129013 board and bluetooth module s/n 134504 can u please help me how to make connections between arduino and bluetooth module and how to get mac address

  73. hello Rui,
    I ma fan of yours great projects…we all are implementing them in our college projects…..I had experinced a problem in implementing this project it is connecting fine with HC-05 module but when i press forward button the motors are not moving …please tell me the possible reason for the following error..please give a bit of your valuable time for my problem..


  74. why i can’t connect to my robot bluetooth? when i click “choose device to connect to” on ur app, then choose my bluetooth name, then suddenly appear “Need bluetooth_Admin permission :neither user 10130 nor current process has android.permission. BLUETOOTH_ADMIN.” why?

  75. If i need to control 2 dc motors, and I have the motor shield, I just upload the code to the Arduino and it works?

  76. sir i have created your project with all the right connections but when i turn on the project one motor rotates and when i connect it to the phone it keeps on rotating and when i press left it stops rotating but the other one doesnt and when i press stop it rotates i have rechecked all the connections. i have even replaced the l293d ic and also reprogrammed but the problem continues. please help me out

  77. Problem : I have connected circuit as given in your diagram but the motors do not corresponds when i try to check by entering 1,2,3 …..
    in the serial monitor . What’s the problem can you explain it ?
    Help me as i am new

      • Thx , a lot Bro .I could control the two DC motors with smartphone because of you .Thx once again .

        PROBLEM : But , When i tested it at that time I Supplied Power through the ‘Cable connected to Computer’. BUT I Want to Power through “9V Battery” . So where should I Plug the ‘Battery’ .Please Help me as early as Possible !!!!!!!!

          • I am using HC-05 Module and Arduino Uno , so how much power should I supply and where should I plug the Battery.I am supplying 3.3 V to HC module through arduino.
            Please give me solution to this problem
            Where should I plug the Battery ????

  78. hi i,
    like ur project and am about to do it i hope.
    but i have one question before i start wich program i use to edite the sorce file for the app
    and in wich programing language its written.


  79. Hi Rui, I really like your stuff and I just published a bluetooth app specifically for controlling Arduino robots. Let me know what you think and if it’s helpful.
    Heres the link –

  80. Hello,
    Very nice projet, but I was wondering if there any possible way to make one motor go Ahead and the other one Reverse so that we can have a perfect turn,
    thanks 🙂

  81. Rui, baixei seu programa para ver como ele é feito pra aprender um pouco, mas o app inventor classic não está mais funcionando… tem outra forma que eu possa ver seu aplicativo? Queria entender os códigos pra aprender… Obrigado e parabéns pela iniciativa!

    • You can use this tool to convert App Invento Classic to App Inventor 2:

      Olá matheus,
      Pode utilizar esta ferramenta para converter:

    • I don’t that file, please read the top description of this blog post.
      This was done for an older version of the MIT app inventor…
      You can also search for Convert classic MIT app inventor to aia file

  82. bro my connections are working i checked in the serial monitor but the motors are not working can u help me in this…. thank u

  83. Hey Sir,

    Thank you for detailed explanations and for all you effort. I also appreciate that you answer all the comments…

    Since I am using your .apk for communication between smartphone and my hc06 I am getting this errror on my phone:

    Need BLUETOOTH_ADMIN permission: neither user 10083 nor current process has android.permission BLUETOOTH_ADMIN

    then it ends the applicaiton.

    Can you help me what might be the issue??

    Your sincerely,

  84. Hi Rui,

    I’d like to modify the app you made for this, but it can no longer be imported into the newer MIT app inventor. I even tried the converter they have, but that did not work. Do you have an updated version of the app source code?

    Kind regards,

  85. hi
    I am using motor controller l293d but I have that board motor controller so what is t the wiring for that you can tell me please.

  86. sir….,
    is it possible to run 4 motors, two motors for vehicle moving and another two motors are run for some special purpose. if it is possible give me some explanation it is helpful to my project.
    thank you sir

  87. Thanks, Rui, this is exactly what I needed to get started. Although I will be using a downloaded app (there are plenty, each sending different set commands), your code is pretty universal and basically helps me put things together and expand it in the future, perhaps by adding the obstacle avoiding feature (in an if/else statement, I suppose statement), etc.

    Guess my first making will be motorized strandbeast (check it out on youtube, guys, it is pretty awesome) and a three-wheeler … which shall be a great encouragement for forther endeavours

  88. Can I replace the L293D IC with an L298N motor driver to control my two DC motors? Do I have to change the code at all if I do?

    • Hi.
      That module should work just fine with the code provided.
      You just need to make sure you wire the DC motor to the motor driver properly.
      Sara 🙂

  89. Olá Rui.

    Primeiro que tudo, obrigado pelo teu esforço em disponibilizares este conteúdo de graça. Muito obrigado.

    Estou a experimentar o teu projeto e, sem mexer em nada no programa, o meu motor assinalado com “motor2” no pin 1 não funciona. Simplesmente parece que não recebe a ordem. Estou a tentar com o Serial Monitor e ainda não passei para o módulo Bluetooth.
    O que é que poderá ser?

    Mais uma vez obrigado pelo teu site,

    • Se não consegue controlar o motor a partir do Arduino IDE Serial monitor significa que algo está errado no seu circuito ou que o chip de controlar os motores não está bem ligado. Recomendo verificar uma segunda vez todas as conexões

  90. Please help me. How can i make to motor motor to rotate slowly.Please help.Very important for my project. The setup is all set but i want the motor to run slowly.

    • Hi Bhanu.
      Instead of using the digital digitalWrite() function and using HIGH and LOW, use the analogWrite function, for example:
      analogWrite(motorPin, motorValue);
      In which motor value is a value between 0 and 255 (255 is maximum speed). This way you can control the speed.

    • Hi.
      This code was built for the companion MIT App Inventor.
      It won’t work with a different application, unless it sends the exact same commands to the Arduino.
      Sara 🙂

  91. Hi,
    thanks for your feedback.
    That question requires almost an entire tutorial.
    What I can tell you right now is that it works like it does with the Arduino… The bluetooth module will establish a communication via the TX and RX pins.
    and your smartphone will establish a communication with the bluetooth module.

    It will also depend in which PIC you’ll be using. you need to read the datasheet…

Leave a Comment

Download our Free eBooks and Resources

Get instant access to our FREE eBooks, Resources, and Exclusive Electronics Projects by entering your email address below.