Skip to main content

MicroBlocks


MicroBlocks

MicroBlocks is a fantastic options for users who enjoy block-coding. There are two supported ways to benefit from MicroBlocks, by using a micro:bit or running standalone with MicroBlocks firmware!


MicroBlocks on micro:bit

In theory, you can use any board (any host) that is supported by MicroBlocks. But we will focus on using micro:bit.

To connect DUELink modules, you need an accessory that adds a JST connector to micro:bit. See micro:bit for options, including LinkBit.

Create a MicroBlocks project on https://microblocks.fun/run/, or download the local version for MicroBlocks' Downloads page.

MicroBlocks IDE

Run any simple block samples to make sure that micro:bit is configured properly. You are now ready for the "Daisylinking" section below.


Standalone with MicroBlocks

This option turns a DUELink module into a host that runs Standalone. This gives any DUELink module a native block-coding option.

While MicroBlocks can be loaded on the entire catalog of DUELink modules, it shines best on one of the Microcomputers, such as DueSTEM and Clipit.

DueSTEM

Clipit

It also works great on CincoBit and PixoBit as micro:bit-style options.

CincoBit & PixoBit

To use the MicroBlocks Engine, replace the default DUELink firmware with the MicroBlocks firmware. All options are already built in the Console. In short, put the board in loader mode by pressing A or LDR button, or by placing the jumper, and then reset the board while doing so. If there is no reset button on your board then simply power cycle the board.

LDR, A, pads

Visit https://console.duelink.com/ and click Firmware on the top menu.

DUELink Console Firmware Menu

You can now connect to DFU in FS Mode device then select the MicroBlocks from the available options. If you do not see DFU in FS Mode then the board is not in loader mode. Go to the loader page and make sure the board is in the loader mode.

Once the firmware is loaded, power cycle the board. You are now ready for MicroBlocks.


Supported Blocks

The MicroBlocks firmware for DUELink supports most blocks. You will be able to read/write digital pins, read analog inputs, and write PWM pins.

Pins numbers are mapped to match the DUELink official mapping; however, the pins are mapped to match micro:bit edge connector on CincoBit and PixoBit.

Capacitive touch is also supported on modules like Clipit and on the large three pads on CincoBit and PixoBit. Reading the level of "capacitive-ness" is done by charging a pin and then measuring the discharge time.

MicroBlocks Cap Touch

tip

Code samples like the one above that don't require an external library can be dragged directly into the MicroBlocks IDE.


Available Services

It is very important to note that once a DUELink board is loaded with MicroBlocks firmware then it becomes 100% reliant on what blocks/libraries/services are offered by MicroBlocks. In other words, you lose the Standard Library.

For example, while you can load MicroBlocks on SD Card module, you do not have SD card drivers nor file system libraries!

This is not a problem in a standard DUELink setup as you will usually have the recommended CincoBit or PixoBit loaded with MicroBlocks but then you have other modules daisylinked on its downlink connector. Those other modules will still be running the standard DUElink firmware. In this case the SD Card module will have the necessary standard libraries, which are commanded by the MicroBlocks firmware.

Cincobit and SD Card


Smiley!

Assuming you using a CincoBit, and you have it loaded with MicroBlocks firmware, we will show a smiley face on the LEDs.

Use the online interface at https://microblocks.fun/run/ or download the MicroBlocks software locally from their download page.

Download

Install the MicroBlocks software.

Install

Plug in the DUELink hardware, the IDE will automatically connect to the device.

Connect

Now we're ready for some block-coding!. Click on the Add Library button and Open the LED Display. This will add the 5x5 LED Matrix block.

Connect

Click on the block itself it will activate the LEDs on CincoBit. Any changes we make are instantly transferred to the device.

Smile and Frown

This program will switch from a "smile" to a "frown" based the pressed button.

Smile and Frown

tip

MicroBlocks maps pins to match DUELink standard pin mapping on all modules, but it will map the pins on PixoBit and CincoBit edge connector to match micro:bit.


Daisylinking

A user can easily Daisylink several modules. In this example, the MicroBlocks special firmware is loaded on PixoBit. The MicroBlocks website/app can now be used to program a PixoBit, which is then commanding the other modules in the link.

PixoBit Daisylinked

tip

Daisylinked modules do not need to be loaded with the MicroBlocks firmware. Only PixoBit (first module) is loaded with MicroBlocks firmware in this example.

When Daisylinking DUELink modules users need to download the DUELink libraries for MicroBlocks from the Downloads page.

Once downloaded, add it to the MicroBlocks' IDE by clicking Add Library from the side menu. Select Computer from the options and navigate to the appropriate file.

Add DUELink Library

This will add all the necessary blocks to control Daisylinked modules.

New DUELink Blocks

In the example below, we'll use MicroBlocks to control an OLED 0.96 Display, a Button, and a Buzzer module Daisylinked together.

New DUELink Blocks

Click on the image below to download the code, drag the downloaded .ubp file into the MicroBlocks IDE. This also brings in all the necessary libraries in the project.

Daisylinked MicroBlocks Project
tip

When saving projects to share with others, use the file save feature in MicroBlocks. Saving picture of script as .png option won't work when using externally loaded libraries like DUELink.