Installation
Unlike MakeCode, MicroBlocks needs to be installed on your computer. While this isn't always a great thing (like where you aren't allowed to install software, at some schools, for example), it does make possible some interesting capabilities.
On the Get MicroBlocks page you can find installers for various platforms. Download and install as is appropriate for your system and launch the app.
MicroBlocks needs to install it's VM (virtual machine) and runtime on your board. In this regard it is much like CircuitPython. Plug in your Circuit Playground Express, double-press the reset button (the small button between the larger A and B buttons. Then select install MicroBlocks on board
from MicroBlocks' About
menu.
In order to use MicroBlocks with your board, you need to connect them. Use the Connect menu for this. You will be asked to select the serial port to use.
Next to the connect menu button there is an indicator. If it's red you will need to do this connection step, if it's green you're good to go.
When the connection is established, the indicator will change to green.
Real Time Execution
One major difference with MicroBlocks is that it's live. By that, I mean that it's a programming environment like MakeCode but it's also like CircuitPython's REPL.
To illustrate, select the Output
blocks from the list on the far left. You will see one at the top of the list of blocks just to the right of that. At the top is one to set the user LED (aka the D13 LED).
That's pretty cool, and applies generally: if you click on a block anywhere in the IDE, it will get executed immediately on the board.
Any blocks that are currently running on the board will have a faint outline in the editor pane. As you make changes, they go into effect immediately on the board.
There's no save required, no downloading to the board, it gets updated on the board immediately, in real time, without you having to do anything. That's pretty cool, and very powerful.
Click on the block. Assuming your board is installed and connected (as described above) the D13 LED on your board will light up. Click the slide switch in the block so that it turns red and click it again. The LED on your board turns off.
Extensions
The out of the box experience with MicroBlocks is fairly generic. You have to dig a bit to get access to additional functionality that the Circuit Playground Express has to offer. You do that with the Library
menu.
Library opens a window that gives you access to the bundled libraries, your desktop, and anywhere on your filesystem. When you start out there will only be the bundled libraries (shown when you open the library window).
There are libraries for various supported boards and various bits of hardware. You'll want to load the Circuit Playground and NeoPixel libraries for this project. Select each one in turn and click Okay
. You will need to reopen the library window each time.
How It Works
MicroBlocks is sort of like MakeCode and EduBlocks, and sort of like CircuitPython. But it's also unlike all of them as well.
The thing that gets installed on your board is the MicroBlocks virtual machine (VM). When you use CircuitPython its VM is installed on your board. That's what reads, compiles to bytecode, and executes your Python code.
MakeCode works a bit differently: your code (which is really JavaScript behind the blocks) is bundled with the runtime and downloaded to your computer as a file that you then copy to your board.
MicroBlocks compiles your program to bytecode, and ships that to your board. the bytecode then gets executed by the VM installed on there.
One big difference is that your block code compiles directly to bytecode, rathering than being converted to another language (Javascript or Python) first. This makes it faster and more flexible since it's one step and there's no third language involved.
The other big difference is that as you make changes, they get compiled, downloaded, and executed. The board is always running the latest valid version of your code. This assumes that you clicked Start
at the top right of the MicroBlocks window.
The MicroBlocks site has a page explaining a bit about how the whole thing works.
Text editor powered by tinymce.