The Microsoft Block Editor is a graphical drag and drop code editor, where you can snap together blocks of code. If you're familiar with Scratch, you can use the Block Editor to write scripts until you become more familiar with Touch Develop. You can convert your Block scripts into Touch Develop scripts if you like.
Create a Block script
- Go to the BBC micro:bit website and click Create Code.
- Under the Microsoft Block Editor heading, click New project.
- Type a name for your script and click create.
A new blank script opens in the Block Editor like this:
There are buttons along the top, block categories on the left, and an empty coding area.
Buttons along the top
Here's what the buttons do:
my scripts exits the editor and takes you back to a list of your scripts. The open script is automatically saved in the cloud.
run executes your script in the web browser, showing you the results on the right-hand side of the screen. See run scripts in a browser for more about this.
compile translates your script into a file that you can run on your micro:bit. See run scripts on your micro:bit for more info.
convert translates your Blocks script into a TouchDevelop script. See convert a Blocks script for more info.
On the left side of the coding area, there are categories that contain blocks (i.e. Basic, LED, Images). Click a category name to see the available blocks.
Add a block
- drag and drop a block into the coding area. The code blocks fit together like pieces of a puzzle.
Remove a block
- drag and drop a block from the coding area, to the trash can icon (lower-right corner)
- drag and drop different blocks so that they fit together like puzzle pieces like this:
Set parameters for a block
- some blocks have options (or parameters) that you need to set. Depending on the block, you may need to choose an item from a list or type a value. For example, on the button is pressed block, you need to choose input button
B. And on the plot and unplot blocks, you need to type numbers (for the x, y coordinates).
Declare a variable
is a place where you can store data so that you can use it later in your code. Variables have a name, a type
, and value. To declare and set a number variable:
- Click Variables from the list on the left.
- Drag and drop the set item to block into the coding area. Click the down arrow and choose new variable. Type a name for the variable and click OK.
- Click Maths from the list on the left.
- Drag and drop the 0 block into the coding area so that it connects to the set item to block. Click on 0 and type a number.
You can right-click on any block and select
Add Comment to attach a comment to the block.
Share your scripts
You can share your scripts with other people by publishing them on the BBC micro:bit website. See publish a script
for more info.
Convert your Block scripts to TouchDevelop
You can convert your Block scripts into Touch Develop scripts if you'd like. This way you can see how blocks in your script translate into Touch Develop functions (see convert a Block Editor script
for more info).