Arduino – Control DC Motor via Bluetooth

Hi guys,

Control DC motor via Bluetooth

Control DC motor via Bluetooth

In this project we will control a DC motor with a smartphone via bluetooth. This project is great to learn more about:

  • DC motors
  • Interfacing Arduino with your smartphone
  • Bluetooth
  • L293D IC


If you don’t have the L293 IC you can make the same circuit using the H bridge, anyway I really recommend you to read more about that and the IC datasheet. There’s plenty of tutorials about that. So Let’s start…

Parts required:

  • 1x Arduino UnoIMG_0244
  • 1x Bluetooth Module (for example: HC-05)
  • 1x Smartphone (any Android will work)
  • BlueTerm application
  • 1x L293D IC
  • 1x DC motor
  • 1x Breadboard
  • Jumper Cables

You just need to follow this schematics (I recommend you to wire the TX and RX only in the last step) :

Screenshot from 2013-02-23 17:15:28

Two common mistakes:

  • You need to remove the RX and TX cables when you’re uploading the sketch to your Arduino.
  • Sometimes people connect the TX from the bluetooth module to the TX of the Arduino… that’s wrong and it won’t work. Make sure you connect it properly, the TX into RX and the RX into the TX.

If the HC-05 Bluetooth Module asks for a password, It’s ‘1234’.

The Arduino code can be download here. Upload this sketch! Make sure you remove the wires from RX and TX otherwise the code won’t upload properly!

For the android communication with our bluetooth module I’ve used the BlueTerm app, It’s completely free, so you just need to go to β€œPlay store” and download it. Then you just need to connect your smarthphone with the bluetooth module. Remember to remove the TX and RX cables. (you can see in youtube video below how that’s done).

I’ve only set 3 commands to control the DC motor:

  • ‘0’ – Turns off the DC motor
  • ‘1’ – DC motor rotates to right
  • ‘2’ – DC motor rotates to left

Check this video to see the circuit in action!

I hope this tutorial had helped you in anyway, you can apply this method to control anything through bluetooth! Thanks for reading, if you tried my code leave a comment or send me an email. If you like this project probably you might like my next ones, so please support me by subscribing my blog and my Facebook page (you can find everything right column )


About Rui Santos

Arduino Tinkerer. Circuits Designer. Electronics Hobbyist. Blogger and Entrepeneur. I live in Portugal and I'm an Electrical and Computer Engineer.
This entry was posted in Arduino, Arduino Tutorials and tagged , , , , , , , , , . Bookmark the permalink.

40 Responses to Arduino – Control DC Motor via Bluetooth

  1. huss says:

    Good stuff. Great Tutorial.
    How can I make my robot, be controlled through bluetooth?
    Here’s my robot,
    I want just 5 commands right, left , forward, back and stop

    • Rui Santos says:

      Yes you can do that by using two L293D ICs…you just need to change the code a bit… And it will work just fine πŸ™‚ i will make a full tutorial about that soon… Im just waiting for a few parts that will arrive in one or two weeks… So make sure you subscribed to receive the updates about my robot. By the way nice robot you have! I’ve subscribed to you

      • huss says:

        Just Subscribed!
        Yes, I’m using 2 SNY motor drivers equivalent to the l293D… The only thing I’m having trouble is choosing an affordable bluetooth Module, and writing the android App(never did before) but I guess I will download yours when you do the new one?

        Also, I’m trying to find a way to make my ping sensor ping wirelessly so I wont need wires like my video shows.

  2. Rui Santos says:

    This is probably the most affordable bluetooth module out there Hc-05 the one Im using. you can buy one for 8$ on ebay. You can use my code but you need to add a new motor to the code and define the forward and reverse button . I will post the robot in 1/2weeks Im waiting for one IC and some others parts i need. You just need to change my code a bit. For the android you will need the blueterm app or any app similar to do that , so you can connect your arduino to the bluetooth module.. I can write the code for you… Its pretty quick

  3. huss says:

    I just purchased the Hc-05 on ebay, takes 10 days delivery. I have all the code written for both of my motors already, all I need to do is some simple tweeks, I can do that pretty simply.

    But I never used the Blueterm app before(I have an iphone, but can get an android), I was wondering instead of sending “0” “1” “2”, there would be actual buttons (Arrows) for the directions.

  4. Rui Santos says:

    Nice πŸ™‚ btw usually the HC-05 requires a pass and its ‘1234’.
    you can use an iphone you just need to find a similar app…
    If you’re familiar with the Arduino IDE, what the blueterm app actually does it connects your smartphone to your arduino via Bluetooth, and it does a serial communication between the devices. So you don’t need to type anything in the serial monitor with your computer, but instead you type on your smartphone
    there are some apps with the 4 buttons that do the exact same job but I’ve never used any… but usually someone made that app just for one particular robot, the easy way is to use an app as blueterm.
    there are some examples in that website, lot’s of those apps work with an accelerometer which I thinks its really good
    My idea for my robot is to control a robot with 2 DC motors through bluetooth with my ipad (with the 4 buttons)
    But as I said before it will require some time as I don’t have the parts yet and I need to learn more about the control with the 4 buttons ….

    • huss says:

      Me too i have an Ipad, I will also look into it. That even sounds like a better idea, thanks for all your help, I will be checking back constantly for updates!

      and when I get my bluetooth, and get it working with my robot, ill check back for help, if i need any, and I will let u know how it goes!

      Thank you

  5. huss says:

    Just last question.

    from the android bluetooth perspective.
    how do you:
    Set 3 commands to control the DC motor:
    ’0β€² – Turns off the DC motor
    ’1β€² – DC motor rotates to right
    ’2β€² – DC motor rotates to left

    Do you do it on the android phone in the app or how?

    • Rui Santos says:

      The commands are set in the arduino code… In the arduino code its where you define the keys that will trigger the movement you want. If you read my code. In the if statements its where i define which keys i want to be pressed and read. You can define whatever key you want (numbers… Letters) the android app just sends the key.

      • Thomson says:

        Hi, I’m Thomson

        i have a project to make a robot. maybe like huss project.
        but i use arduino leonardo. i use dual motor controller. but i wanna it run on my iPad. i don’t know how to make it work on my ipad. i need your help. and how to make ipad app to control the robot.
        may you give me best solution.
        which the best one, Arduino leonardo or arduino uno?
        thanks for your article it’s very useful for me
        send me by email.

      • Rui Santos says:

        Hi Thomson!
        You can use the Arduino uno or the Arduino Leonardo they both are capable to do that project, you can read this post for more information and see the advantages between the 2 boards
        But in conclusion for that project it doesn’t make much difference they’ll both work just fine πŸ™‚

        I didn’t made the app I’m running on my smartphone… And I don’t know much about iOS programming, I was thinking in making one but actually I’ll only be able to do that If I’ve buy a Mac or something otherwise would be really hard to create one app. with just my ipad… or with my linux computer with a virtual machine…
        I didn’t found any similar app for my iphone/ipad that’s why I used my android…
        Actually I don’t know any free app that does the same as Blueterm..

  6. Vladimir says:

    Hi Rui !
    Great project. I am new to the Arduino community and I am getting started on a personnal porject in whitch I would like to control a :
    – a small speaker that display a sound
    – a small fan
    via bluetooth.
    I would like that device to be as small as possible and powerd by a battery.
    Witch hardware Arduino would you advise me ta base it on ?
    Thanks so much for your answers !

    • Rui Santos says:

      Hi Vladimir! Thanks for your support, I’m really glad you enjoyed it!
      You can buy any Arduino to control the fan and the speaker, I would recommend you to buy the Arduino Uno or the Arduino Duemilanove. You can buy an original or a clone, It’s easy to find on ebay.
      I don’t know what you want to do when you said control a small speaker, I don’t know what’s your project about.
      But with the Bluetooth module, a smartphone and an Arduino You can control the fan and the speaker for sure!
      And the Arduino Can run with a 9V battery !
      If you have more questions just let me know or just talk about your project!

      • Vladimir says:

        Thanks for those elements. It helps a lot.
        The idea it to have the sound go thru the running fan to study how disformed it souds like while the beat frequence is modified and the fan speed is as well. (listen to music thru a fan, you’ll understand what I am talking about).
        On the hardware configuration, I have been looking further, and there is still a challenge :
        1. The bluetooth needs to be able to transfer data and music which will be stored on the smartphone that commands it
        2. I need to make sure that the arduino is “smart” enough to understand a music signal AND data signals that controls teh fan speed. And it has to transfer the music part to the autoamplified speaker.
        So, still not sure what hardware configuation to use (especially, which bluetooth receiver between the large choice), but if you have any ideas, tey are more than welcomed πŸ˜‰ !!!
        Thanks !

      • Rui Santos says:

        To be honest I don’t know exactly how you can do that, but If I understood the real goal of your project, I must tell you that probably the Arduino It’s not the best platform to do that.
        You can’t send music like a mp3 file or something to your Arduino trough bluetooth, I don’t know if there’s any shield that allows that… but with the Arduino itself you can’t.
        The most similar project I can think about It’s to create the song you want to analyse in the Arduino IDE using the Tone function and control the PC fan with that sound (Basically the voltage could be connected to a buzzer/speaker and you could hear the tones of the music, or simply connected to a Fan controlled by the voltage )

        I don’t think I’ve helped you much, I’m sorry…

  7. Vladimir says:

    Well, thanks, that’s a lot allready !

  8. telmo says:

    Onde posso comprar o modulo bluetooth?

  9. Cinder says:

    I got to the last step but when I enter the values (0,1,2) nothing happens. All I see is a number on my phone. On the video the commands show up as “Motor:right” for 1. All I get is 1 on my phone.

    • Rui Santos says:

      try to insert the numbers in the serial monitor with your computer, if nothing happens probably it’s a problem with your IC, motor or wiring…

      • Cinder says:

        Hey that worked but I cannot control the motor with my phone. When I use the serial monitor I am able to control the motor and the inputs (the number 0,1,2) appear on the screen of my phone. It seems like the circuit is connected correctly and the bluetooth module is working as well, but when I try to control the motor with my phone nothing happens, I just get a number as I told you before.


  10. Rui Santos says:

    thats really weird… if it’s working with your computer should be working with your android, i don’t know what can be done then…
    but it says something like this: ‘connected to linvor’?

  11. Cinder says:

    No it says:


    • Rui Santos says:

      I don’t know what can be wrong because it seems that everything is correct… and a lot of people actually tried this and worked…
      and if it works with the arduino serial monitor the circuit is correct. it can be a problem with the bluetooth module I guess
      the last thing that it can be a mistake (the TX from the bluetooth module goes into the RX from your arduino and the RX from the bluetooth goes into the TX from the arduino).

  12. Can we do programming Arduino over Bluetoooth??

  13. Vijay Patil says:

    Can you please share Android Source Code with us so that we can modify according our need.

  14. My bluetooth Module HC-05 Receives Data from Arduino , and Forward it to PC/Mobile , but does not Transmit Data from PC/Mobile to Arduino ? Any Advice?

  15. Lloyd Irvin says:

    No matter if some one searches for his required thing, therefore he/she desires to be available
    that in detail, thus that thing is maintained over here.

  16. Luca Crisi says:

    I’m probably asking something stupid, but…

    1 – Since a l293d can drive 2 motors (yes, TWO!!)… why buy another one?
    2 – Where’s your ANDROID CODE? I only see the Arduino code, so I’ll have to figure out the android part by myself?
    3 – A graphical interface with some buttons on the phone side would be nice (and also very easy to implement).

    Anyway, nice tutorial, after all.

  17. Rishav Kumar says:

    Good work!!….I have tested …itz working fine!!

    • Rui Santos says:

      I’m glad you found this tutorial helpful.
      Please check my new website: Thats where I’m posting my new projects..
      I don’t post anything more on this website…

      If you liked my project, check my most recent ones… on my website here:

  18. Peter says:

    Hi Rui Santos, thank you for your sharing how to do arduino project here firstly. I had tried to use of your arduino uno codes in virtual simulation of Proteus for controlling 2 DC motor using L293D and Atmega328p. However, the simulation program prompted me error message and I don’t understand why the error occurred since I had sorted out all possible problems before. Could I send you the proteus simulation file for your reference and then can you point out how I can slove the simulation problem please? I would like to complete the simulation firstly before launching the hardware circuit development processes. Many thanks.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s