MIT App Inventor is a drag-and-drop block-based editor which can make Android Apps. You can use App Inventor to control mBots through an extension.
This document is available in a .docx document.
What’s new in Version 1.9
- Uses Bluetooth 4.0 (BLE), which simplifies the connecting experience. Now you may connect your mBot with even only one button.
- Added support for 9g mini servo
- Now sensor values are read through events, easier for programming.
Add the mBot Extension to MIT App Inventor
MIT App Inventor is a drag-and-drop block-based editor which can make Android Apps. You can use App Inventor to control mBots through an extension.
Step 1. Go to MIT App Inventor’s website; create or open a project.
Step 2. In the Extension category of the Palette, click Import Extension. And switch to the URL tab in the opening dialog box.
Step 3. Paste the following link to the text box, and click Import.
http://appinventor.makeblock.com/MBot_v1.9.aix
Step 4. Click OK in the Rename extension dialog.
Step 5. Now you can see mBot in the Extension category. Drag it onto your phone screen.
Connect to a mBot with your Android App
Whenever you want to connect the robot, use the Connect to robot block.
Your phone will start searching for the nearest robot and connect it if close enough.
Tip:
If you run “Connect to robot” block again, the phone will close the previous connections and try to connect again.
Tip:
If you cannot connect the robot, please check: 1. Whether Bluetooth on the phone is enabled; 2. Whether the robot’s power is on. And of course, your phone needs to support Bluetooth 4.0.
Issue commands to your robot
After the robot is connected, commands regarding to motors, lights, sound and servos become available.
Here is an example of telling the robot to move forward when the button is clicked:
Read Sensor Values
In version 1.9, you need to “open” a sensor first, then use the sensor values in “received sensor value” blocks.
For example, the following blocks “open” the ultrasonic sensor when the mBot is connected:
Then you can use the sensor value in the “when mBot receive ultrasonic value” block. This is an example of obstacle avoidance:
List of Blocks