thumbnail

How To Use App Inventor With Arduino

1.3K Flares 1.3K Flares ×

UPDATE 23-12-2013: http://appinventor.mit.edu changed their whole website… So the source file that previously you could use to edit on their website, only works with AppInventor version 1.0 or also called classic that you can see here http://appinventor.mit.edu/explore/classic.html Click the button: “Invent your own Apps now” . This project still works just fine with my  app and with my Arduino code. But you can only edit the source code on Appinventor classic version. I’ll try to update the source code in the next 4 weeks or something. I’m currently working on another projects that I need to finish right away.

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:

(You can download all the source code used in this video, by clicking share!)

Parts:

parts

Schematics

[Schematics]

 Tips:

  • 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)

56 Comments

  • Roger Schoeni

    Reply Reply October 19, 2013

    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

    • Rui

      Reply Reply October 23, 2013

      Hi,
      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,
      Rui Santos

  • auroral

    Reply Reply December 1, 2013

    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…..

    • Rui Santos

      Reply Reply December 4, 2013

      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!

      • auroral

        Reply Reply December 26, 2013

        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…

        • Rui Santos

          Reply Reply December 28, 2013

          Hi auroral,
          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.

  • dui santoso

    Reply Reply December 14, 2013

    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=0×11″
    What’s mean and what i should do?please help.

    • Rui Santos

      Reply Reply December 15, 2013

      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

  • dui santoso

    Reply Reply December 23, 2013

    Hi,,Rui.
    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.

    • Rui Santos

      Reply Reply December 25, 2013

      Hi dui,
      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:
      http://randomnerdtutorials.com/ascii-table/

  • dui santoso

    Reply Reply December 24, 2013

    Hi,,Rui

    Today i just read article about ASCII number. I think i have known the answer.hehe.thankyou

    • Rui Santos

      Reply Reply December 25, 2013

      yeah exactly!
      The ASCII table was the answer.
      I’m glad you could figure that out. That was awesome.

  • marcello

    Reply Reply January 17, 2014

    Hi
    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:
    http://code.google.com/p/app-inventor-for-android/issues/detail?id=2002&q=bluetooth&colspec=ID%20Status%20Summary%20Owner%20Reporter%20Stars
    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…

    • Rui Santos

      Reply Reply January 18, 2014

      Hi Marcello,
      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,
      Rui

      • juanskarlos

        Reply Reply March 4, 2014

        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.

  • 100rb

    Reply Reply January 29, 2014

    hello can you tell me that which app I use in this project

    • Rui Santos

      Reply Reply January 29, 2014

      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 !
      Rui

  • Darkdrummer

    Reply Reply February 10, 2014

    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?

    • Rui Santos

      Reply Reply February 10, 2014

      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?

  • Mike

    Reply Reply February 20, 2014

    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?

    • Rui Santos

      Reply Reply February 22, 2014

      Hi Mike.
      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,
      Rui

  • arijit

    Reply Reply February 22, 2014

    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.

  • juanskarlos

    Reply Reply March 4, 2014

    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′??

    • juanskarlos

      Reply Reply March 4, 2014

      Saw the posted answer, Never mind, lol, Thanks tho

      • Rui Santos

        Reply Reply March 4, 2014

        I’m glad you found the answer juanskarlos!
        Thanks for trying my project.

        Have a nice day,
        Rui

  • Eirik

    Reply Reply March 7, 2014

    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?

    Thanks!

    • Rui Santos

      Reply Reply March 12, 2014

      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!

  • sabri

    Reply Reply March 18, 2014

    hi rui,
    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.
    please help

  • sabri

    Reply Reply March 18, 2014

    hi rui,
    why when i want to connect my phone to bluetooth module it says

    Runtime Error
    Need BLUETOOTH_ADMIN permission: Neither user 10130 nor current process has android.permission.BLUETOOTH_ADMIN.

    please help.

    • Rui Santos

      Reply Reply March 19, 2014

      Do uyou have by any change another smartphone that you can test my app with?
      Which is the android version you’re running?

      • sabri

        Reply Reply March 19, 2014

        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?

        • Rui Santos

          Reply Reply March 25, 2014

          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…

          • sabri

            March 26, 2014

            well then I guess i’ll just figure it out myself..
            thanks anyway.. u made my final year project a lot easier..

          • Rui Santos

            March 29, 2014

            I’m glad I could help! :)

          • sabri

            May 5, 2014

            hi Rui,
            i’m using the app inventor to modify your BlueArd.apk design.
            i’m curious.
            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.

  • Tumpa Saha

    Reply Reply March 30, 2014

    Thank you very much

    • Rui Santos

      Reply Reply April 5, 2014

      You’re welcome Tumpa!

  • juan manuel

    Reply Reply March 31, 2014

    hello, you know 507 error fix the problem?

    • Rui Santos

      Reply Reply April 5, 2014

      What that error tells you besides 507 error?
      Which android version are you using?

  • SJ

    Reply Reply April 3, 2014

    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!

    • Rui Santos

      Reply Reply April 5, 2014

      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.

  • mr

    Reply Reply April 15, 2014

    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??

    tq

    • Rui Santos

      Reply Reply April 18, 2014

      Hi,
      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

  • joe

    Reply Reply April 30, 2014

    is there anyway to buy anyone of your project

    • Rui Santos

      Reply Reply May 3, 2014

      Hi Joe,
      Sorry I don’t sell any of my projects…
      Thanks for asking

  • PARTH TEMKAR

    Reply Reply May 1, 2014

    hello sir,
    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

    REGARDS
    PYT

    • Rui Santos

      Reply Reply May 3, 2014

      Hi Parth,
      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.

  • devv

    Reply Reply May 19, 2014

    Pretty section of content.
    Anyway I’ll be subscribing your facebook page

  • Fabian

    Reply Reply May 21, 2014

    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.?

    • Rui Santos

      Reply Reply May 26, 2014

      Hi Fabian,
      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…

  • Rangga

    Reply Reply June 20, 2014

    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)??

    • Rui Santos

      Reply Reply July 4, 2014

      So if you don’t to want to use bluetooth, how are you supposed to send data to your android phone?

Leave A Response

* Denotes Required Field