1 of 3

Web Button | 1. Button Scripts

Connect the BBC micro:bit to MicroBlocks.

This tutorial shows how turn a micro:bit into a web button to control other devices connected to the Mozilla Web Things gateway.

CC BY-SA 4.0

Add Libraries:

Add these scripts then press, double-press, or long-press button A:

Web Thing

Button Events

2 of 3

Web Button | 2. Connect to Gateway

After programming and testing the buttons on your micro:bit, connect the micro:bit to the Web Thing gateway (see Web Light guide for setup instructions).

The icon on the Things page changes when the A button is held down.

CC BY-SA 4.0

Open the Thing and select Event Log to see event history:

Open the Mozilla WebThing gateway in a web browser (http://gateway.local) and add your Web Button.

3 of 3

Web Button | 3. Add Rules

CC BY-SA 4.0

First, make sure both Things are plugged into the Mozilla WebThing gateway and have been added to the Things page.

Then, select Rules from the gateway menu.

Drag the icons for the Button and Light into the rule and choose properties to turn the Light on when the Button reports “pressed” event:

Create a second rule to turn the light off. The Rules page shows two rules:

Pressing the button quickly will make the light go on. Pressing and holding will make it go off.