MicroBlocks
MicroBlocks is a blocks programming language for physical computing.
Image of the pilot version of MicroBlocks version 2
It runs on microcontrollers such as the micro:bit, Calliope mini, AdaFruit Circuit Playground Express, and many others.
Code Interactively
MicroBlocks is a live environment. Click on a block and it runs immediately, right on the board. Try out commands. See and graph sensor values in real time. No more waiting for code to compile and download.
Multitask Naturally
Want to display an animation while controlling a motor? No problem! MicroBlocks lets you write separate scripts for each task and run them at the same time. Your code is simpler to write and easier to understand.
Run Everywhere
MicroBlocks runs on many different boards, but your scripts are portable. Buttons, sensors, and display blocks behave the same on all boards with the relevant hardware. MicroBlocks even simulates the micro:bit 5x5 LED display on TFT displays.
Unplug and go!
MicroBlocks downloads your code as you write it. When you like what your program does, just unplug the board and you're good to go. Make a pocket game, a fitness app, or light-up clothing that goes wherever you do.
MicroBlocks BLE Extension
The extension makes connecting to microcontrollers very easy. It does all the difficult work for you using the blocks it contains.
Methods:
Connect
Connects to the MicroBlocks device with the given name
. Import the “Bluetooth LE” extension and use the “Bluetooth LE” block from that extension as the first parameter of this block. The second parameter is the name of the board you want to connect to such as “MicroBlocks XYZ” where XYZ is the board’s three-letter BLE ID.
Parameter | Type |
---|---|
bleExtension | component |
name | text |
Disconnect
Disconnects from the currently connected BluetoothLE device, if any.
IsDeviceConnected
Returns true if a device is connected.
Return Type: boolean
SendMessage
Send the given message to MicroBlocks.
Parameter | Type |
---|---|
message | text |
Events:
ConnectionChanged
This event is run when a device is connected or disconnected.
Parameter | Type |
---|---|
isConnected | boolean |
MicroBlocksMessageReceived
This event is run when a MicroBlocks message is received.
Parameter | Type |
---|---|
message | text |
This documentation was generated using Akshat Developer's Documentation Generator.
Examples
Connect to a board
The name of a MicroBlocks BLE enabled device is MicroBlocks followed by a space and the 3 letter BLE id.
If the board is a Raspberry Pi Pico W, then the name is Pico followed by a space and the 3 letter BLE id.
If your board has a display, it will show the BLE id when powering up. If the board doesn't have a display, you can get the BLE id by using the BLE id block that you can find in the Input category of MicroBlocks. The board has to be connected to the IDE to show the BLE id.
Receive a single value from the microcontroller
MicroBlocks Code
App Inventor code
Receive multiple values from the microcontroller
MicroBlocks Code
App Inventor Code
Receive multiple values from the microcontroller using keywords.
MicroBlocks Code
Using a space behind the keyword to separate keywords and values.
App Inventor Code
Splitting messages on the first space character found.
Send a message to the microcontroller from App Inventor
App Inventor Code
MicroBlocks Code
This block looks for a specific message
This block handles any message
Send a message with a value to the microcontroller from App Inventor
App Inventor Code
MicroBlocks Code
Example Project Beating Heart
beating_heart.aia (225.8 KB)
beatingheart.txt (4.3 KB)
Rename the beatingheart.txt file to beatingheart.ubp. The community doesn't allow files with the ubp extension.
I used the Tools Extension from @Taifun to keep the screen on while connected to the microcontroller.
Links:
Stable version of MicroBlocks v1
https://microblocks.fun/downloads/latest/
https://microblocks.fun/run/microblocks.html
Pilot version of MicroBlocks Version 2
https://microblocks.fun/downloads/pilot/
https://microblocks.fun/run-pilot/microblocks.html
Read about the new version 2 and why you could use that instead of version 1.
Extension version 1
fun.microblocks.microblocks.aix (12.6 KB)
We had already a number of meetings with members from the App Inventor development team and App Inventor Foundation, to see if this would benefit students learning physical computing.