Note: This post is outdated. For a recent version see Getting Started with MIT App Inventor 2 and Arduino.
This project’s source file for the android app is outdated, because it was built using the old MIT APP Inventor Classic software, that is no longer supported. However, this project still works if you convert the files to the recent format here.
We also have other projects that you may find useful:
If you like Android Apps and Arduino take a look at our course: Android Apps for Arduino with MIT App Inventor.
How To Use App Inventor With Arduino
After so many requests, I’ve decided to create this quick tutorial! I hope you enjoy.
This will help you understand how App Inventor works and how it can interact with your arduino via bluetooth.
Watch this video tutorial
Download all my source code below
- Arduino Sketch
- BlueLED Source files (for editing purpose)
Note: If you want to edit my app this is what you need to do: After you download this folder make sure you unzip it. Only upload the BlueLED.zip into App Inventor.
- Arduino UNO – read Best Arduino Starter Kits
- 1x Bluetooth Module (for example: HC-05, click here to read my review here about this Bluetooth module)
- 1x Smartphone (any Android will work, I’ve only tested with Samsung Galaxy Ace)
- Android Application (you can download it in the next step)
- 1x 220Ohm Resistor
- 1x LED
- 1x Breadboard
- Jumper Cables
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!
- 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′.
- Before Testing my “BlueLED” app, test if you’ve made all the connections correctly. How you can do that? Simply enter numbers (’1′, ’0′) into your serial monitor and your LED should be turning on and off.
I hope you found this useful!
Do you have any questions? Leave a comment down below!
Thanks for reading. If you like this post probably you might like my next ones, so please support me by subscribing my blog and my Facebook Page.
P.S. You don’t have a Bluetooth Module yet? Read my review here about the one I’m using in this tutorial!
P.P.S. Check a Similar project made by me using MIT App Inventor. (Click here)
72 thoughts on “How To Use App Inventor With Arduino”
Many thanks for the tut! Appreciated
Could you show by any chance how a led could be dimmed with a slider in the app?
thanks for stopping by!
Right now I have to finish some projects, but that looks like an interesting thing to do.
But as I said I simply don’t have any time left to do that.
But if you explore a bit the app you’ll find a way.
Good luck with your project,
Hi,Rui,i am newly to app inventor, how can i open the BlueArd Source files,because i want to edit it and i cant get how to open it in app inventor.please help me…..thank you…..
You need to download my code and unzip the zip file.
then upload the .zip file called “BlueLED” directly into App Inventor.
I hope this works for you!
thanks you for your information….it really works on the app inventor 1 but not the appinventor 2….realy2 thank you for your help Rui…
no problem… yeah they changed their platform recently.
In a few weeks I’ll try to create some new apps with app inventor 2.
right now I need to finish a couple of projects.
Convert it here:
Hi santos,,i have tried this project and exactly follow the instruction.but,it’s seem didn’t work.i can’t turn on or off the led using my phone. And if i see the dialog in arduino written like this “avrdude: stk500_getsync(): not in sync: resp=0x11”
What’s mean and what i should do?please help.
Please make sure you check all the connections. Follow my exact schematics.
the dialog in the Arduino, is something that you don’t need to worry about. It always say something similar to that.
You just need to pay attention if it says. “Upload Complete”.
Make sure you follow my schematics… and before you try with the bluetooth module send ‘1’ and ‘0’ through the serial monitor.
If the LED is turnning on and off, the circuit is working!
Here’s a list of common mistakes while using bluetooth modules:
– 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′.
– Before Testing my app, test if you’ve made all the connections properly. How you can do that? Simply enter numbers (’0′, ’1′) into your serial monitor and your LED should be turning on and off
i have tried your suggest and result is great.i have little modify with 5 led,in this case on and off in each led.so i need command ‘1’ until ’10’. But,,why in command number ’10’ is not working??it’s mean i only can control 4 led. So,,what command that i must write in order to control more than 4 led?thanks for support.
You can send any number you desire you just need to right the correct code for your code. My code is just an example!
Remember that the android app use’s Decimal numbers and the Arduino reads chars.
So for example the android app receive a 48 and the Arduino will read like a ‘0’.
See the ASCII Table for all the values:
Today i just read article about ASCII number. I think i have known the answer.hehe.thankyou
The ASCII table was the answer.
I’m glad you could figure that out. That was awesome.
i downloaded your project to get an app for bluetooth connection. but i always get the “error 507: unable to connect – is the device turned on?”
The devices are already paired.
After googling I found this statement:
Did you know this problem before? and what is your workaround? I`m surprised that nobody got this problem before I got…
Please just tell me, you know this bug und your smartphone uses an android version lower than 2.3, as its described in the link I`ve posted or tell me what I`m doing wrong…
that’s a weird error that I wasn’t aware off..
The bluetooth feature works fine for me…
My smartphone runs with version 4.01 and it works just fine.
It’s probably a compatible problem with your smartphone.
Some of my friends and a lot of people tested my app with version superior to the 2.3 android version with success.
Some people also sent me some variations of my app.
So it might be a problem with your smartphone.
Not sure how yo help you as a lot of people is using this app successfully.
Have a nice day,
Hey Marcello, try turning Secure off , I try this version and I didn’t have this problem, I did and app like this on App inventor 2 and I was having that problem: Error 507. while I was working on the app I turn off and on the arduino(Unplugging) and also restart the bluetooth service in android, then connection Works!, By the way I’m using SAM Note 3.
hello can you tell me that which app I use in this project
If you watch my video and read this post on the top.
You’ll see everything you need to know.
I’m using MIT APP Inventor which is a good way to create android apps with drag and drop…
If you want to download the source code, simply click the Like or tweet button and the code will unlock…
Let me know if you have any more questions !
Thanks for the awesome code but I am experiencing a problem even though I followed your directions spot on. Circuit is working correctly (tested 1 and 0), app is connecting to HC-05, but when I press the LED ON button, the led will not turn on. I checked proper ASCII chart numbers and I also did your suggestion where I disconnected the TX/RX cables before upload of the Arduino sketch. Any advice?
Thanks for trying my project.
Seems like you’ve done everything properly… it should be working…
how did you wire the Bluetooth module?
RX BT module -> TX Arduino
TX BT module -> RX Arduino
Did you wire like that?
I am wondering, I’ve only seen examples of people controlling one LED this way. Is it possible to have several LED’s hooked up and control them using one Bluetooth card? Or is this best left to an ethernet shield?
You can control anything you want with a unique bluetooth module.
You just need to change the android app and the arduino code in order to do that.
(add more buttons and more if statements)
This app establish a bluetooth communication with your your arduino.
when you press one of the buttons. (On or Off)
It sends a character via serial communication to your arduino.
You arduino receives that information and It does something.
So you can control anything you want.
If you want more help please tell me a bit more about your project..
Have a nice day,
Hey. i dont not get any option in andriod app inventor to upload source code. the only option i have is import .aia from my computer.
thanks for your interest in my project.
please read the update at the top of this page.
the source code for this project only works with the previous version of MIT app Inventor.
Check here my most recent tutorial with the new MIT App inventor
Hey Rui, thanks for the tut, I have a question that I’ve tried to find the answer beforehand, but couldn’t get it. Why 49 and 50 while in android code Its expected ‘1’ and ‘2’??
Saw the posted answer, Never mind, lol, Thanks tho
I’m glad you found the answer juanskarlos!
Thanks for trying my project.
Have a nice day,
Hey Rui! I guess your tutorial is clear, however i can’t get it to work.
I have wired everything like you, I have tried sending serial commands from the PC and it works. I just can’t get it to work with your app.
I do get a confirmation that the app is connected to the HC-05.
Do you have any tips on further troubleshooting?
Can you try this project with another smartphone?
It can be a compatible problem or something..
Are you wiring the bluetooth module properly?
The TX from the bluetooth goes to the RX of the Arduino.
The RX from the bluetooth goes to the TX of the Arduino.
I hope this helps Eirik!
why my bluetooth module cannot be detected by the app?
i can’t connet it to my phone.
the circuit is working perfectly when i enter 0 and 1.
why when i want to connect my phone to bluetooth module it says
Need BLUETOOTH_ADMIN permission: Neither user 10130 nor current process has android.permission.BLUETOOTH_ADMIN.
Do uyou have by any change another smartphone that you can test my app with?
Which is the android version you’re running?
thanks for the reply.
well i’m using android 4.2.2
when i use bleuterm app it works perfectly fine but not with blueLED app.
i try to google it and it comes to something about manifest problem which is something i’m not very familiar with.
it seems that the app that is downloaded from Play Store that only work.
do you have any idea how to solve this problem?
yeah it should work just fine with my android and it’s also version 4.2.2 at the moment.
you might need to change some of your bluetooth setting I guess.
That never happened to me…
well then I guess i’ll just figure it out myself..
thanks anyway.. u made my final year project a lot easier..
I’m glad I could help! 🙂
i’m using the app inventor to modify your BlueArd.apk design.
in the block of “BluetoothClient1.Send1ByteNumber”, you use number 49, 50, 51 to start and stop the motor instead of using number 1 to start and number 0 to stop.
can you please explain it to me? thanks.
Thank you very much
You’re welcome Tumpa!
hello, you know 507 error fix the problem?
What that error tells you besides 507 error?
Which android version are you using?
hello ! great tutorial!
I have a problem where I can’t find a list of device to connect to.
when i press the choose device to connect to, the screen is just blank and device list does not show up.
I have tried it with android 4.4.2 and 2.3.7. On both phones, cannot detect devices.
Any advices? Thank you in advance!
That never happened to me Sj,
I have no idea what might be… can you try with another smartphone?
Please re-check all the bluetooth setting and make sure everything is properly.
Hi Rui Santos,
I have problem with multiple screen.. how i want to connected BluetoothClient1.SendBytes in Screen2 and Screen3 with Screen1?? because i have set up BluetoothClient1.connect in Screen1..any idea??
that never happened to me, I think that by default MIT App inventor stays connected trough the multiple screens…
So I’m not sure what the problem might be… Sorry
is there anyway to buy anyone of your project
Sorry I don’t sell any of my projects…
Thanks for asking
i checked out your project and was very eager to build it. so i ordered the bluetooth module and its not HC-05 or 06
i ordered sparkfun bluesmirf silver
and from 4 days ive been trying to connect the module with my phone but its not getting connected and ive noticed that none of the people have made projects with bluesmirf and appinventor.
yes, ive tried to connect the bluetooth module with other apps of android and it gets connected but its not getting connected with the app inventor apps.
pls help me pls
i need to submit it as a project in college and i do have 100 marks for it. pls
Have you checked the most common mistakes? If not please try again…
is you project working when you control the LED trough the serial monitor?
Have you change anything from my app?
Please first try with the exact .apk file I provided before you change anything.
Pretty section of content.
Anyway I’ll be subscribing your facebook page
thank you Devv!
Hello rui, it work excelent ¡ i test it and now i understand number 49 and 50 for led on and off, but i want programmer with the number 1 and 2 in app inventor so when arduino receiver 1 or 0 make led on or off. have you any suggestion for modification in the code in arduino.?
In the Arduino code you just need to change those if statements to the numbers you want to trigger the LED.
Those numbers must be the same in the android app…
hello, I need your help, how make an application using appinventor which can send data from arduino to Android app with USB connection (without bluetooth)??
So if you don’t to want to use bluetooth, how are you supposed to send data to your android phone?
comment back sir thanks
hello rui santos, it can happen even without the bluetooth module … is by using a USB OTG like this video https://www.youtube.com/watch?v=yaifCo8u7T8
Can you make a tutorial like the video, and make it free. I would much like to thank to you!
sir is there a product such as that arduino here in the philippines?
thanx rui for u useful tutorial
could use plz guide me “MIT APP INVENTOR” code controlle DC motor in 2 directions using accelerometer
Unfortunately I don’t have the time to create a tutorial on that subject…
can you tell me how step,if i want edit the BlueArd.apk?
You can edit the app with the older version of MIT App Inventor, It’s explained at the top of this blog post.
Hey! I wonder if anyone can help me with my problem. I am trying to finish this project as my thesis but after a month trying different ways to solve it, I really don’t know what else to do now.
I am building my app with App inventor 2 and with my arduino. I have a gas sensor which via bluetooth sends the numbers to the app and whenever the value of the gas increases the phone has to give a notification and to speak some text.
My problem is that I am trying different ways of receiving the value and I can not find the correct way to receive the numbers and then with a math block is needed to compare if that value is higher or lower than another value.
So I will explain what I have and let’s see if it helps you to understand what I am doing wrong:
Inside the timer it checks first if the bluetooth is connected, if so, set variable Sensor to Call Bluetooth BytesAvailableToReceive. And if button On is not enabled, set value text to get global Sensor.
And right after that it comes the comparison, if get global Sensor is higher or equal than 700 then set Color Alarm red, call notification and call VoiceAlert.
And here I just receive a number 1 on my label value. I have also tried different ways of receiving the value but none of them has worked yet, so if you could please help me to solve this I would really appreciate it.
Thank you in advance for your help.
im newbie to make androis app. i follow your tutorial video on youtube. i got some of problem. whats mean error 507 ? it said unable to connect.is the device turn on ? . i make it for my final year project and this presentation on end of april. what should i do ? please help me
thx for code..
I am using 1.6.8 arduino version..
When I read coming data from serial monitor , I read 128 0 0..I wrote that : Serial.println(state);
And I also my led is not working..
And when I push the off button , I read 0 0 0 …What can I do ?
Have you modified the code?
Im trying to do a similar thing like this tutorial.
I want to turn leds (in one circuit) with the android, but when it turns off (by a sensor) I want to another led (in another circuit, separately) turns on and when it turns off (by a sensor)……. and go like this with 8 circuits.
How can I do that?
i would like to say thank you ,and please make your post with materials where can accses them
You’re welcome. All the information that you need is in this blog post (schematics and code).
Thanks for asking,