App Inventor + Iot: Control RGB Led With Micro:Bit I/O Pins: Level: Advanced
App Inventor + Iot: Control RGB Led With Micro:Bit I/O Pins: Level: Advanced
Level: advanced
This tutorial will help you work with App Inventor + IoT and control
a RGB LED on a micro:bit controller.
source .aia
Hardware list
In this project, we are going to control a RGB LED (which is
connected to Micro:bit) using App Inventor. RGB means this knd of
LED actually has three different color LEDs inside (red, green and
blue).
Here are the components you need for this project:
● BBC micro:bit dev board, 1
● breadboard, 1
● wires, 4
● RGB LED (common cathode), 1
Demo video: https://youtu.be/TQcRy1JkFBc
Blue
Green P0
GND P1
Red P2
GND
GND 2 1 0
App Inventor
This app lets you make an RGB LED light up in four different colors
by clicking buttons on your app. First, log into MIT App Inventor site
and create a new project.
Designer
You should complete the App Inventor + IoT Basic Connection
tutorial to make a basic connection to the micro:bit device. If you
prefer, you can download the completed .aia file here.
The remaining steps all build off of the starter code for Basic
Connection tutorial and its .aia source code.
First, we need to add the necessary extension.
● In the Palette window, click on Extension at the
bottom and then on "Import extension" and click
on "URL".
○ Paste micro:bit extension URL:
http://iot.appinventor.mit.edu/assets/com.bbc.mi
cro:bit.profile.aix
● Add a Microbit_IOpin component to your app
by dragging it onto the Viewer, set its
BluetoothDevice to "BluetoothLE1" (Don’t
forget!).
Let’s add more components into our app to control micro:bit’s I/O
pins.
● From the Layout palette, drag in a
TableArrangement component.
• Set its width to "Fill parent", height to
200 pixels, row to 2 and column to 3.
• Set its Visible property to false, it will be
set to true after the Bluetooth connection
between micro:bit is established.
● Add five buttons into the tablearrangement
component, and set their text properties to
"Red", "Green", "Blue", "White" and "Off",
representing different colors of the RGB LED
light.
Brainstorming
1. Try to light up the RGB LED with different colors, such as red
and blue lighting up together to shine in purple.
2. Add a SpeechRecognizer component to control the RGB LED
by your voice command.