In this post I’m going to introduce you to the MIT App Inventor 2 software and I’m going to show you what you need to quickly getting started building Android apps that interact and control your Arduino.
Here’s the contents that are going to be covered in this post:
- Introducing MIT App Inventor 2
- Why MIT App Inventor 2 is a good choice?
- Accessing MIT App Inventor 2
- How to control Arduino with MIT App Inventor (Bluetooth)
- MIT App Inventor Overview
- Projects with MIT App Inventor
- Android Apps for Arduino with MIT App Inventor 2
Introducing MIT App Inventor 2
MIT App Inventor 2 is a simple and intuitive free service for creating Android applications. If you want to start with MIT App Inventor, you don’t need to download or install any program in your computer as the software is cloud-based, so you build the apps directly in your browser (Chrome, Mozilla, Safari, Internet Explorer, etc).
For instance, you only need an internet connection for building the apps.
Why MIT App Inventor is a good choice?
- MIT App Inventor 2 is intuitive and simple to use.
- You don’t have to be an expert in programming or design to build awesome apps that can do useful stuff.
- Creating the design is as easy as selecting and placing widgets in the smartphone screen.
- The code is done with drag and drop puzzle blocks.
Anyone can learn how to build their own apps with MIT App Inventor 2 with a few hours of practice.
Accessing MIT App Inventor 2
To access MIT App Inventor 2 go to http://appinventor.mit.edu/explore/ and press the orange Create Apps button.
To access the app builder, you need a Google account. Follow the on-screen steps to login into MIT App Inventor 2. After that, you’ll be presented with the following dashboard (we’ll cover how to use the dashboard in the MIT App Inventor 2 Overview section):
How to Control Arduino with MIT APP Inventor (Bluetooth)
To establish a connection between the Arduino and your Android app, you need a Bluetooth communication protocol. For that, you need a Bluetooth module.
The most common Bluetooth modules used with the Arduino are the HC‑05 bluetooth, HC-04 and HC-06.
For more information about the bluetooth module, you can check this blog post: Reviews – HC-05 Bluetooth Module
The Bluetooth module works with serial data. This means that the Arduino sends information and the Bluetooth module receives it via serial (and vice-versa).
The following figure explains how the information flows from the Android app to the Arduino.
Your smartphone sends information to the Bluetooth module via Bluetooth. Then, the Bluetooth module sends the information via serial communication to the Arduino. This flow also works the other way around: the Arduino sends information to the Bluetooth module that sends it to the smartphone via Bluetooth.
MIT App Inventor Overview
Go to http://appinventor.mit.edu/explore/ and press Create Apps button.
Next, click on Start new project as shown in figure below.
You’ll be asked to give your project a name. As we’re just exploring the MIT App Inventor 2 features, you can name it test.
Click OK. Your project is automatically saved.
If you go to Projects > My Projects you can see all your saved projects.
Click on the project name to open the app builder.
You’ll be presented with the Designer tab as shown in the following figure.
At 1) you select whether you are on the Designer or in the Blocks Editor tab. With MIT App Inventor you have 2 main sections: Designer and Blocks. The designer gives you the ability to add buttons, add text, add screens and edit the overall app look.
The Blocks section allows you to create custom functionality for your app, so when you press the buttons it actually does something with that event.
2) The Palette contains the components to build the app design like buttons, sliders, images, labels, etc…
3) It’s the Viewer. This is where you drag the components to build the app look.
4) Components. You can see all the components added to your app and how they are organized hierarchically.
5) Properties. This is where you select your components’ properties like color, size and orientation.
Open the Blocks editor tab.
In the Blocks editor tab, you have several sections:
1) contains the built-in blocks for creating the app’s logic. This is what makes the app define the buttons functionalities, send commands to Arduino, connect to the Bluetooth module, etc. You have several blocks grouped by categories:
- Control: if/else statements, while loops, etc…
- Logic: True, False, equal, not equal, etc…
- Math: math operators.
- Text: blocks that deal with text.
- Lists: blocks for handling lists.
- Colors: blocks to handle colors, like choosing a color, make color and split colors.
- Variables: initialize variables, setting variables values, get variables values, etc…
- Procedures: procedures are like functions. A procedure is a sequence of code blocks with a given name. Later, you can call that sequence of blocks instead of creating the same long sequence.
Inside each group, you have blocks that you can drag to the Viewer 2). In the Viewer, you drag the blocks and join them in a specific way to make something happen.
We recommend that you navigate inside the blocks section and explore what’s inside. The blocks look like puzzle pieces that fit into each other or not. If you can’t do something with certain blocks, they won’t fit.
In the backpack 3) you save code blocks to use later. You move blocks to the dustbin 4) to delete them.
Projects with MIT App Inventor
This was just a quick introduction to the MIT App Inventor. Now, its time to start building apps!
Here’s a list of our popular Arduino and MIT App Inventor projects:
- Android App – RGB LED with Arduino and Bluetooth
- Arduino – Control 2 DC Motors Via Bluetooth
- Control your Arduino with Voice Commands
Android Apps for Arduino with MIT App Inventor 2
If you like Android Apps and Arduino take a look at our course: Android Apps for Arduino with MIT App Inventor
This is a step-by-step course to get you building cool Android applications for Arduino, even with no prior experience! A collection of 8 + 1 Projects.
I hope you’ve found this post useful.
Thanks for reading,