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).
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: http://ai2.appinventor.mit.edu.
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.
- 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!
Code
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, https://randomnerdtutorials.com
* 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:
Serial.begin(9600);
}
void loop() {
//if some date is sent, reads it and saves in state
if(Serial.available() > 0){
state = Serial.read();
flag=0;
}
// 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!");
flag=1;
}
}
// 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");
flag=1;
}
delay(1500);
state=3;
stateStop=1;
}
// 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){
Serial.println("STOP!");
flag=1;
}
stateStop=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");
flag=1;
}
delay(1500);
state=3;
stateStop=1;
}
// 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){
Serial.println("Reverse!");
flag=1;
}
}
//For debugging purpose
//Serial.println(state);
}
Note: before uploading the code, make sure you have the TX and RX pins disconnected from the bluetooth module!
Parts Required
- Arduino UNO – read Best Arduino Starter Kits
- Bluetooth module HC-04 or HC-05 or HC-06
- 1x L293D IC
- 2x DC motors
- Breadboard
- Jumper wires
You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!
Schematics
Follow the schematic diagram in the following figure to wire your circuit.
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
Troubleshooting:
- 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,
Rui
P.S. If you don’t have a bluetooth module, read my HC-05 review here.
Nice !
Thanks for your feedback!
sir …
can i get coding for Blueard that how to make application of GO,BACK,FORWARD ,REVES,STOP IN APP inventor
Can you tell me the program for this project
it was awesome and i used it for my bluetooth controlled robot!!!
and it worked fine!!!!!
Hi Rui,
I wanted to purchase physical copy of your book
Image URL: https://randomnerdtutorials.com/wp-content/uploads/2014/09/rnt-download-sidebar.jpg
18+ Random nerd Tutorial Project
What is the process ? Can we order online ?
Please respond.
I am in India -> Bangalore
Hi Raj, i am Renu from bangalore. You can download the pdf and get it printed.
I know that thos is veey old thread.. But my question is will thos wprk with 2 1/2 hp 90v perm magnet motors? Belt driving. I need to sync 2 dc motors .. Position and both motors have different loads but i meed them to position sync.. Great thread by the way.. Thanks
Hi Angelo,
The app should work with any motors. You only have to make the right circuit and change a little code from my example to make it work. But the app should work regardless of the motors
sir …
can i get coding used here
Yes, it has a link on this page to download
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! : ) )
Wow, thanks for sharing
Hugs from Brazil
Wagner Oedis
Thanks so much for your feedback Wagner!
I’m glad you enjoyed it!
Hugs from Portugal!
Obrigado!
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!
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 ? .
thank’s
Hi Iman! thanks for leaving a comment!
I don’t have the Java code… I recommend you to read this tutorial that I’ve just released and you’ll understand how you can create your own apps for android… without using Java! Let me know if this answered your question.
https://randomnerdtutorials.com/how-to-use-app-inventor-with-arduino/
okay rui im understand.
my question . why u dont use motor shield ?
i think for use motor dc we must use motor shield
yes you can definitely use one if you have one!
the L293D it’s used by most of the motor shields…
So if you have a motor shield go for it.
hello rui
can i use a L298 Dual H-Bridge IC instead of L293D IC to control 12V DC motores
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
Thanks for the fast reply friend
Another question. Did you use any voltage divider for the output to the Bluetooth module?
Do I have to use a voltage divider?
I’m not using the voltage divider but you can use one…
Some people prefer to do that way!
So you are not using a divider. I think I will do just like you.
I will let you know soon
Thanks
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
Hi Nattawt!
Thanks for stopping by!
I’m using the HC-05 and my Bluetooth module only has 4 pins!
Which one are you talking about?
Send me a link please and I’ll take a look!
here it is.
http://www.arduitronics.com/product/55/bluetooth-serial-module-hc-05-master-slave-mode
Thank you for your kindness
here it is.
http://www.arduitronics.com/product/55/bluetooth-serial-module-hc-05-master-slave-mode
Thank you for your kindness.
I think It will work with that bluetooth module… but please do a bit of research first… I’m not completely sure.
How can i convert a zip file to get load on my anroid phone….
First Unzip that file and then inside it’s a .apk file.
That’s the file that you’re going to install into your smartphone
Thanks for trying my project!
I know this is a very old post already, but let me chip in on the voltage divider issue. I have been using hc05 modules since I think 2011 on an arduino. To be exact I used 4, that eventually all went dead. So on average they lasted about 2 years, but that’s still relatively short. Had them connected without any voltage divider on the Rx pin coz that ‘should be OK’. Nevertheless, i never had such a high turnover rate on electronic components as with the hc05, except maybe for sd cards in a raspberry pi.
Have ordered a new hc05 but this time i will be using a voltage divider.
I guess that the 5volt level perhaps somehow slowly deteriorates the rx pin of the hc05
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
http://www.aliexpress.com/item/LC-05-bluetooth-serial-interface-module-wireless-serial-interface-module-through-the-wireless-module-free-shipping/638543403.html
That’s really weird … Never happened to me… the voltage divider is supposed to stable the connection.. but I thought It wasn’t necessary, because It always worked well for me.
I’m sorry :S
Did you tried again after that? It’s still not working?
the small LED’s don’t blink?
I’m using the HC-05 (something similar to this: http://www.ebay.com/itm/Arduino-Wireless-Serial-4-Pin-Bluetooth-Transceiver-Module-RS232-Backplane-/131017379824?pt=LH_DefaultDomain_0&hash=item1e813e8ff0)
HEY please can you tell me did you use the same code for Dual H-bridge? L298N
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 Rui,
Awesome tutorial!
I’m having some problems finding that IC. If so, how would I wire that in? Thanks!
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: https://makeradvisor.com/tools/arduino-motor-driver-shield/
L298N: https://makeradvisor.com/tools/l298n-motor-driver/
Good Luck with your Projects,
Rui Santos
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: https://randomnerdtutorials.com/download
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!
Hai Rui
I wanna ask you something about the bluetooth, if i use LC-05 Bluetooth Serial Module Master (Slave Integrated) it can work too? Because in my place is pretty hard to find HC-05
Here’s the picture:
http://indo-ware.com/produk-2391-lc05-bluetooth-serial-module-masterslave-integrated.html
And when the programming begins? Before we set all components to PCB or after?
Thanks !
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!
hi. will this also work if we are going to use the accelerometer sensor of the smartphone?
.
Hi Mark,
This project and idea can be used with the accelerometer of the smartphone.
But in order to do that you will need to create a new app for your smartphone.
the one I’m using on this tutorial was created with MIT app inventor.
I’ve also made a tutorial using that platform:
https://randomnerdtutorials.com/how-to-use-app-inventor-with-arduino/
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?
Thanks
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
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,
Peter
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.
Hi Peter.
I’m really glad you got it working!
Have a nice day,
Rui
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.
Peter
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?
Thanks,
Peter
Hi Peter,
Thanks for contacting me.
You can use all my code and all the resources provided on this website under those terms:
https://randomnerdtutorials.com/terms
So feel free to edit and share my code.
Please contact me here telling where and how you’ve used my code. I always love to hear that.:
https://randomnerdtutorials.com/contact
Thanks again,
Rui Santos
P.S. Don’t forget to show me your project 🙂
Hi Rui,
of course, I just reference your codes for evaulation only and then I will write my owned code with adding other function, such as LED controlled by Andriod for the car, etc.
Hi Rui,
Many thanks for your info and help. If I completed my project, I will show you later. 🙂
Olá Rui,
É possível fazer uma aplicação parecida para controlar step motors?
Abraço
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!
Abraço,
Rui
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.
Awesome tutorials..Thank you very much.Sir ,how can i connect HC05 module with PIC mcu ? please help…
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…
hi..is 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:
http://www.adafruit.com/category/44
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,
Rui
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.)
https://randomnerdtutorials.com/how-to-use-app-inventor-with-arduino/
Please watch the video on that post where I explain everything. Let me know if you have any questions!
Rui
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.
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.apk
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 project.property 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?
Thanks
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.
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!
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?
You can use either the 5V or the 3.3V… it’s you choice.
yes I recommend you to use a voltage divider !
Awesome..that worked! Thanks
Also i tried creating your app in MIT App Inventor 2..it shows an error when i try to connect HC-05 in the list..the error says unbound null..
Here is the image of my blocks..
http://postimg.org/image/h2amfiwbj/
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
Thanks Merry Christmas for you too!
You can create a voltage divider just like the guy in the link below did:
http://www.thalin.se/2013/01/fritzing-veroboard-and-breadboard.html
You don’t need the voltage divider for regulated power supplies.
But to be 100% sure always use the voltage divider.
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,
Rui
Happy new year!
I’m bad english language. Go! with left and right with reverse working how to solve.
Hi bataa,
Happy new year!
I didn’t understand your question, could you please repeat again?
thanks
Press Right ! GO working is like .
error 516 unable to write transport endpoint not connected
Sir gudeve happy new year can i ask u a question how can i edit ur android app??
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.
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.
Thanks
Hi Mike!
Thanks for trying my projects,
I would love to see what you come up with,
You can submit your project here:
https://randomnerdtutorials.com/contact
Good luck with your project,
Rui
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′ ){
digitalWrite(8,HIGH);
}
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.
if(state==’1′){
digitalWrite(8,LOW);
}
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,
Rui
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 🙂
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
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 module..it 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…
hi rui, first of all great project man….but there is a problem with BLUEARD…..it shows an error….. “Need BLUETOOTH_ADMIN permission: neither user 10115 nor current process has android.permission BLUETOOTH_ADMIN”
that error happens you when you’re installing the app?
or while you’re trying to connect to the bluetooth module?
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:
I apologise but I don’t speak french I only speak English or Portuguese sorry.
If you want to download my source code for this project, you can either click like on the locked content.
Or you simply enter your email here:
https://randomnerdtutorials.com/download
If you have any problems feel free to contact me here:
https://randomnerdtutorials.com/contact
while i connect it…
Can you share with me a print of the problem or something?
Otherwise It can be anything :S
Thanks Thanks Thanks !!!!!
Great job!!!!
Hi Panayiotis,
I’m glad you enjoyed it!
all the best,
Rui
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
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
Hi Raj,
To create this android app I’m using MIT APP Inventor, as it says on the top of this post.
You can download all my code by clicking “like” or “tweet” and my code will unlock.
Or you can go to this page and download all my projects for free:
https://randomnerdtutorials.com/download
I’m not using eclipse…
please read this posts below and watch the video tutorial:
https://randomnerdtutorials.com/how-to-use-app-inventor-with-arduino/
It’s a simple introduction to MIT App inventor by creating a blink LED project.
I hope this helps,
let me know if you have any more questions!
Rui
Hi,
Thnx for tutorial, it really helped a lot. Can you please tell me from where I can download your app.
The app can be download from this page. Just click like or tweet.
Or you can go to this page enter your email and you’ll have access to all my projects:
https://randomnerdtutorials.com/download
hey rui
i want screen shot of appiinventor bluetooth connection designer block……
and i want to learn how to creat app in app inventor ….
It’s easier if you download my app and change the code sharmila…
Watch this tutorial first to learn more about MIT App inventor: https://randomnerdtutorials.com/how-to-use-app-inventor-with-arduino/
you can download all my project here: https://randomnerdtutorials.com/download
Have a nice day,
Rui
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!
Rui
Curto bué os teus projectos, são uma boaajuda nos meus, bom trabalho, Rui
Obrigado José!
Vou lançar mais um projecto com bluetooth amanhã (sábado) com o novo MIT App Inventor 2.
Abraço,
Rui
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.
Hi john,
thanks for asking!
My bluetooth module the HC-05 (has a max voltage of 3.3V to 6V)
It says on the label also
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…
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
That’s awesome Abdulrahman!
I’m really glad I could help!
Have a nice day,
Rui
hi sir, what other types of bluetooth module that are compatible with this project?
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,
Rui
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,
Rui
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 !
Have you tried my project first?
What have you done so far with MIT App Inventor?
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
There’s a built-in function called LongClick, that should do exactly what you’re looking for.
Here’s a print screen to show you exactly that:
http://bit.ly/1laTakG
thanks for the information sir
You’re welcome Hafis!
Thanks for reading,
Rui
Hi,
does this bluetooth module HC-06 works correctly with this project?
The link is here
fabtolab.com/HC-06-bluetooth-module?search=HC-06%20Bluetooth%20Module
yes Amarendra, that bluetooth Module should work just fine!
thanks for my last question.
I want to ask one more question
How we will supply power to arduino in wireless projects?
Hi Amarendra,
You can supply the arduino with a rechargeable battery for example!
thanks for assisting me in this project.
its working…
Awesome Amarendra!
I’m glad to hear that.
Ok thanks Rui! i`ll give it a try!
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… http://tinypic.com/r/wwnty9/8
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,
Rui
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
Stefan
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,
Rui
When will you upload the app inventor 2 sketch?
Hi Sonia,
I don’t have time to update those projects right now.
And they work just fine with Beta MIT App Inventor.
You can check my two most recent project with MIT App Inventor 2.
https://randomnerdtutorials.com/control-your-arduino-with-voice-commands/
https://randomnerdtutorials.com/android-app-that-sends-a-message-to-your-arduino/
Both Beta MIT app Inventor and the new version work really similar.
Have a nice day,
Rui Santos
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…
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…
Hi Najam,
I’ve never changed the baudrate but I’ve found a good tutorial
http://mcuoneclipse.com/2013/06/19/using-the-hc-06-bluetooth-module/
I hope this helps!
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!
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,
Rui
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 (http://www.cytron.com.my/viewProduct.php?pcode=BLUEBEE) + XBee Shield (http://www.cytron.com.my/viewProduct.php?pcode=SHIELD-XBEE)
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?
Which app didn’t work for you?
you can use the accelerometer function on the app.
It’s provided on MIT App Inventor.
The apps that I’ve develop and download. Both didn’t work. Yes, I already include accelerometer function on MIT App Inventor in my app.
But what have you tried?
hi
im doing the same project.here in tutorial i cant see that you connect a power supply for l293d driver.
yes you can’t see any power supply, but just notice a cable attached to Arduino, that is supplying power to Arduino.
yeah that’s true.
I’m supplying the arduino with the USB port of my computer
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
What exactly is not working for you?
what have you done so far?
Hello!
could you help to build an app like that by sharing the screen shots of “DESIGNER” AND “BLOCK”?
THANKING IN ADVANCE
Sorry right now I don’t have the time to create that tutorial mitun…
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…
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)?
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.
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 ?
Boas Vitor,
O Arduino começa a fazer barulho?
Isso tambem acontece com um simples LED a piscar?
Não , foi a primeira vez que aquilo aconteceu-me e não percebi muito bem , vou desmonta–lo em principio de novo e voltar a montar para experimentar outra vez .
Okok depois diz-me se já está a funcionar.
Abraço
Funciona já perfeitamente , devia ser um fio mal posicionado , obrigado 🙂
Ainda bem Vitor!
Fico contente que esteja a funcionar,
Abraço
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 Rui
Nice project!
Do u hv any idea of how to control the speed of the motor using app inventor and corresponding code for arduino?
I saw a video in youtube.
Here is the link:http://www.youtube.com/watch?v=7JXLQWzQITM
Plz reply asap if u can help.
Thanks in advance
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 🙂
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 Tyler,
Those numbers 49,50, etc… are not random numbers I’ve decided to attribute.
Those are numbers from the ASCII table.
Please take a look at it here: https://randomnerdtutorials.com/ascii-table/
48 decimal in the android app means ‘0’ char in the arduino and so one
Hi Rui
Good project!
Thanks.
Hi Zsolt,
If you read this tutorial: learn.adafruit.com/adafruit-motor-shield
You can combine my project with that tutorial and control your the DC motor with the shield.
I hope this helps,
Rui
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!
Please contact me trough the contact form for more details.
https://randomnerdtutorials.com/contact
Thanks!
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
http://digitalhacksblog.blogspot.in/2012/05/arduino-to-android-turning-led-on-and.html
but it get crashed on pressing “On button”
thanks.
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,
Rui
Hi,
Excellent Work!!!!!!!
But can’t find this BLUEARD App, so can u please help me with the download of BLUEARD app.
Thanks Shantanu!
you can download the app by clicking “Like” or “tweet”.
Or go to this page: https://randomnerdtutorials.com/
thanks again!
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!!!!!!!!!!!!!!!!!!
Thank you for your words!
Let me know if you need further help!
All the best,
Rui
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
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
Hi arun,
Thanks for your feedback!
Sorry I don’t have the .aia file for this project.
This project was done with the first version of MIT App Inventor.
(If you read the update at the top of this page, you’ll see how you can upload this code into the older version of MIT App Inventor an edit my app.)
I hope this helps,
Rui
P.S. You can check a more recent project using MIT App Inventor with the new version:
https://randomnerdtutorials.com/android-app-that-sends-a-message-to-your-arduino/
https://randomnerdtutorials.com/control-your-arduino-with-voice-commands/
its ok rui santos. i will try this app with mit app inventor 2, and im also eagerly waiting for your new projects and posts, i request you to post your new ideas soon in your website
Hi arun,
Thank you for your feedback! More projects coming out pretty soon!
Hi Rui, if is to add in 2 limit switch between the motor to let it toggle forward and reverse, is it possible?
Yes I think so!
Which is exactly the switch you’re talking about?
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…
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??
Can you send me the links to those devices?
hello friend can do with leonardo
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
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?
Hi bill,
Have you tried your bluetooth module with other projects?
Are you sure it’s working?
how far are you trying to connect?
This is my first project using it. Is it just defective? I’m trying to connect from about a foot away.
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
hei Rui,,,,if i want to change the pin from arduino….can it still be working ….
Hi bonney,
which pins you want to change?
If you make the appropriate modficiations to the Arduino code, yes you can change the pins
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!
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!
You can simply create a delay(10000) that waits for 10 seconds… that’s not the best way, but it works
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
Hello Rui, thanks for tutorial. Can I use the L298 shield for this?
http://www.robofun.ro/shields/shield-motoare-l298-v2 this is the one, it connects to arduino through pins 3, 5, 6, 9. Any major changes i have to do in the code? Regards!
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
hi, i want to ask, can i use HC-06 instead of HC-05?
Hi Sam,
This project works just fine with that bluetooth module, since both HC-05 and HC-06 are the same.
Have a nice day,
Rui
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!
Thank you for your input!
Have a nice day,
Rui
At a time how many Bluetooth device can i connect to the mobile…..
You can only be connected to one bluetooth device at a time.
good day sir . .is it possible for a 12v DC motor ?????….
Yes you can do that with a 12V DC motor.
Here’s a good tutorial for that: http://www.instructables.com/id/Use-Arduino-with-TIP120-transistor-to-control-moto/
sir should i program first the arduino before connecting the bluetooth module??????
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 . . .
Good job . It is a very good tutorial.
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)
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!
I can’t find your app blueard
Hi kevin,
It’s below the heading “Download all my source code below”, click to download and install the application in your smartphone.
(It’s the BlueArd.apk file)
i hav tried ur project its working fine.. thanks
You’re welcome!
I’m glad it worked.
Hi all, here every person is sharing these know-how, therefore it’s fastidious
to read this blog, and I used to go to see this webpage every day.
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.
Hi,
The apk download link is not working.
https://dl.dropbox.com/s/382jpx4opdfq43c/Control%202%20DC%20Motors%20Via%20Bluetooth.zip
I’ve just tried the link myself and it works… Please try again.
Thanks,
Rui
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?
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.
Hi Rui
Would this set up work with 360 servos, or would it need altering?
Thanks
Hattie
You have to change the arduino code to work properly with servos.
Check the example code for the servo library in the Arduino IDE examples tab.
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 🙂
What is the program
Which program? The Arduino IDE? MIT APP Inventor?
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 “[email protected]” it would be nice.
thank you
i have downloaded the android app from zip file.
do i have to do any other programing to it again or simply connections are neaded
If you follow exactly my tutorial you don’t need to configure anything else.
Thanks for asking,
Rui
Should i do any programming to Arduino-micro controller
Yes you have to upload the Arduino sketch I’ve mentioned in this blog post.
Thanks,
Rui
Hi Sir,
I am new to MIT App…
I want to edit the MIT App how to edit/import the Bluetooth project in MIT App.
It is asking .aia file extension…the bluetooth zip folder does not have this file.
Please help.
Thanks in advance.
Pls respond.
Raj
Please read carefully the top update at the beginning of this blog post.
My application/editing files only work with the older version of MIT App Inventor,
Thank for trying my project,
Rui
Dear Sir,
Thank you very much for quick response.
Very useful link.
Able to import the code base given for Bluetooth.
Thx
Hi rui ^^
so i tried the codes and the serial monitor replied properly but the dc motors are not moving.. any idea why this happened?
Hi doms,
Does you bluetooth module operates at the same baud rate as mine?
Can you share your code android to me ?
Thank you so much!
You can download the file right on this web page. Thank you,
Rui
Wow..
nice project Rui..
i have question for PWM on PIN 1 also connect to PWM on PIN 0?
i see your schematic in your post –>> http://i2.wp.com/randomnerdtutorials.com/wp-content/uploads/2013/09/DC-motor-Schematics.png
thank you
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
Buenas Rui Santos ! Quería la programación con el arduino uno 2 motores dc independiente controlado vía bluetooth como el del enlace: https://randomnerdtutorials.com/arduino-control-2-dc-motors-via-bluetooth/ La podría publicar o mandarla al correo.
Gracias…!
Hi,To take a picture of the blocks?
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..
Thanks
Can I use hc-06 bluetooth module??
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?
Hi Rui
i was requesting for the .aia file that i have to import in the app inventor how may you help me
We’re a group of volunteers and starting a brand new scheme in our
community. Your website offered us with useful
info to work on. You’ve done an impressive activity and our whole community can be grateful to you.
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?
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
i need a code for controlling , 2 dc motor with bluetooth by smart phone
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
Did you remove the bluetooth module from the TX and RX lines while testing to send commands via serial monitor?
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 !!!!!!!!
Depending on the battery that you’re using it might not work if it does not supply enough current to your bluetooth module
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 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 ????
Hi Rui ,
How can I get the code of the app blue Ard ?
and thank you 🙂
You can download the code from this page.
It was created using the Mit app inventor beta version
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.
regards,
Please read the top of this blog post!
Thanks,
Rui
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 – play.google.com/store/apps/details?id=appinventor.ai_mark.Jarvis
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 🙂
Yes, you can change the code to do that
Well, I am kind of a begginer so I was hoping that u could help me by giving me some hints. Thanks man!
Hi,
can you please share the code?
thanks
A.
You can download all the code used directly from this blog post. Everything is in a .zip folder
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: convert.appinventor.mit.edu
Olá matheus,
Pode utilizar esta ferramenta para converter: convert.appinventor.mit.edu
Is ardiuno r3 board I used in this project
You can use any Arduino compatible board
sir how can i view the screen of you android apk so i can edit it what application should i use?
Please read carefully the top of the blog post for those instructions.
Thanks!
u gave everything but u didn’t gave coding for this
It’s on the download link in the blog post…
Thanks,
Rui
can i get code used in dis ?
best project but some times the motor gets out of control
Are you using DC motor that are 5V rated?
sorry, may you send me the app inventor (apps code to smartphone via bluetooth) to my email, please?
thx,
hi Rui,
may you send me that aia file ? because i want to edit the app in app inventor,please ??
thx Rui
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
Thanks,
Rui
wow sir you are genius.i like your all project.
Thanks for reading my projects,
Rui
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
I’m not sure… What exactly happens?
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,
Alihan
I’m not sure. Some readers experienced that error, but I don’t know the solution… Thanks for reading,
Rui
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,
James
Search for MIT app inventor classic to AI2 converter and you should find a website that allows you to convert the older files to the new MIT app inventor
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.
I don’t have any information for that exact board..
Thanks for asking,
Rui
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
Yes, but I don’t have any tutorials on that exact subject…
Pls help i cant fine source code. I click share
The code is on this exact web page, simply click the download link…
Hello sir, can i have your original source for AIA file
I don’t have the AIA files, please read the top message at the top of this blog post
Good contribution!
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
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.
Regards,
Sara 🙂
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,
Pedro
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
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.
Regards,
Sara
Hello sir, is it fine if i use other app instead of MIT? and is the code works the same?
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.
Regards,
Sara 🙂
Hi.
You need to change the code to be compatible with your own application.
Regards,
Sara 🙂
Is there any mit coding if changing the IC to motor driver?
Hi Raja.
We just have the example for the motor drive in this tutorial.
Regards,
Sara
Hey very good project bro, but can you send the connection with L298 motor driver.
thanks
Hi.
We don’t have a guide for that motor driver with the Arduino.
But we have a guide with the L298 motor driver with the ESP32.
The wiring is similar.
Here is the article: https://randomnerdtutorials.com/esp32-dc-motor-l298n-motor-driver-control-speed-direction/
I hope this helps.
Regards,
Sara
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…
Hi
I tried this project.I powered Arduino with power bank and Dc motors with 4AA batteries.I used L298N motor driver module.But dc motors not running.I check dc motors with direct current and its working.Bluetooth Module and Motor Driver is also working.Can you help me with this?
Do we have any specifications regarding the ic driver position
Hi! i am interested in your project! May I know which schematic diagram you are using? I am currently using tinkercad, however, there are limited components in there.
Having trouble with this at the moment. Anyone trying in project in 2023/2024?
I have a Bluetooth connection but the motors aren’t running when I press on a command and I’m getting the message “Broken Pipe.”
Any tips for this issue?
I’m pretty sure I wired everything right, unless there’s some certain things you gotta do when uploading the code on IDE.
I have followed this tutorial: https://randomnerdtutorials.com/arduino-control-2-dc-motors-via-bluetooth/ and made no changes at all to the instructions. However, when I use the app, everytime I press forward, it will keep going forward forever and will not STOP even when I press STOP and then after this a broken pipe error will occur? Is there a way to remedy this or how can I alter the code so that the forward button only drives motors forward for a couple of seconds?
Help would be much appreciated.