Getting Started with Microsoft Block Editor
BBC micro:bit microbit Getting started with Block Editor This Kitronik University Resource is a part of the BBC micro:bit partnership and is an in depth guide into getting started with Microsoft Block Editor. BBC micro:bit microbit _microbit_logo_870

Getting Started with Microsoft Block Editor for the BBC micro:bit:

The Microsoft Block Editor is a drag and drop editor for the BBC microbit that provides a simple introduction to programming. Blocks snap together to build programs and are grouped by the type of function they do. When a group is selected, the commands in the whole group are highlighted and can be selected. It's a great introduction to programming for those with little or no experience.

Course contents

Selecting blocks

BBC micro:bit microbit _microbit_using_microsoft_block_editor_870 1. Select a block category from the list on the left hand side of the page. 2. Select a block from the selected category and drag it to the workspace area on the right. 3. Snap new blocks onto existing blocks in the workspace area. As the new blocks are dragged into the workspace, the editor highlights the connecting parts of each block when they are in a valid position to snap to existing blocks.

Saving scripts

Scripts are automatically saved on your computer's hard drive when you are not logged in. You can access older scripts when you press the 'My Scripts' button in the top left corner of the editor.

BBC micro:bit microbit _microbit_saving_script_870

If you want to switch computers or save the progress of a current script; click on the 'my scripts' button in the top left corner of the editor:

BBC micro:bit microbit _microbit_my_scripts

Once you have clicked on the 'my scripts' button, it will take you to a dashboard with options on what to do with the selected script. Options include saving your script for editing later, exporting the script to another computer (as a .jsz file), cloning the script (for someone else to edit), deleting your script and publishing the script to the BBC micro:bit website. BBC micro:bit microbit _microbit_exporting_script_870

How to Delete Blocks using Microsoft Block Editor

You can delete blocks in three ways. You have to select and highlight the blocks you want to delete (the edges change colour to yellow when the blocks are selected): 1. Press the DELETE button on your computer. 2. Select and drag the selected blocks into the 'bin' shaped icon in the bottom right hand corner of the editor.

BBC micro:bit microbit _microbit_delete_blocks_bin

3. Select the block and right-click on the selected blocks. A drop-down list will appear and select the 'Delete Block' option.

BBC micro:bit microbit _microbit_deleting_block_870

Changing a Program Name

A program name will be randomly assigned when the editor is first loaded. To change this; simply click or touch the current name of the program at the top of the editor. You should get a cursor with a light blue surround text box. You can now type in the new name for your program. The editor should automatically save your changes when you are online. If you don't have an internet connection, press the save icon to save your changes. BBC micro:bit microbit _microbit_changing_script_name_870

Complete list of available blocks

LOOPS BLOCKS

BBC micro:bit microbit microbit_forever
FOREVER Block The FOREVER Block is one of the most commonly used Block commands. All of the commands that are placed in a forever loop are run in order and then over and over forever!
BBC micro:bit microbit microbit_loops_while_do
WHILE DO Block The WHILE DO Block will repeatedly run the commands contained within it while the test condition is true, The test condition block snaps to the right of the 'while' text. Once this condition is no longer met, the program will continue on to the commands below this block.
BBC micro:bit microbit microbit_loops_while_do
FOR (I) DO Block The FOR (I) DO Block repeats a code a fixed number of times. You can specify which code is repeated using the drop-down menu and add a number specifying how many times you want it to be repeated.
BBC micro:bit microbit microbit_loops_repeat
REPEAT DO Block The REPEAT DO Block repeats the attached commands a set number of times.

LOGIC BLOCKS

BBC micro:bit microbit microbit_logic_if_do
IF DO ELSE Block The IF DO ELSE Block tests the condition snapped to the right of the 'if'text. If the condition is 'true' it will execute once the blocks  snapped to the right of the 'do' text. If 'false' it will execute once the blocks snapped to the right of the 'else' text. The 'cog' wheel (when clicked on) lets extra 'else if' and 'else' elements to be added to this command. This allows for different commands to be run if different test conditions are met.
BBC micro:bit microbit microbit_logic_true_false
BOOLEAN VALUE TRUE/FALSE BlockS The BOOLEAN VALUES TRUE/FALSE Blocks are used when there are only two opposite answers to the command. Boolean is a logic where the answer can be either yes or no or anything you specify to be the opposite of one another.
BBC micro:bit microbit microbit_logic_and_or
BOOLEAN BINARY OPERATORS: AND (conjunction); OR (disjunction) BlockS The BOOLEAN VALUES AND (conjunction)/OR (disjunction) Blocks are used when two blocks need to be compared. The AND block evaluates to true only if both A and B are true, the OR block evaluates to true when either A or B are true.
BBC micro:bit microbit microbit_logic_not
BOOLEAN NOT Block: The BOOLEAN NOT Block is used when you want the opposite (negation) of A.
BBC micro:bit microbit microbit_logic_equal_to BBC micro:bit microbit _logic_more_thanmicrobit_logic_less_than
BOOLEAN COMPARISON OPERATOR BlockS The BOOLEAN COMPARISON OPERATOR Blocks are operator blocks within Boolean logic. These include =, !=, <, >, <= and >=. A numerical value can be inserted into both sides of these blocks in order to make the function work.

MATHS BLOCKS

BBC micro:bit microbit _maths_number
NUMERIC VALUE Block The NUMERIC VALUE Block is used to enter numeric values. These are Integers (whole numbers). The value defaults to '0' but can be changed. This Block is often used in Blocks such as the Comparison Operators Block described above.
ARITHMETIC BINARY OPERATION Blocks The ARITHMETIC OPERATION Blocks are used to perform an arithmetic (maths) operations on two items. For example by adding them together. It returns the result of this operation. This Block has spaces to place the variable or values to perform the operation on. The drop down box in the centre allows the selection of the operator type (there are five you can select).
BBC micro:bit microbit maths_absolute_of
ABSOLUTE VALUE Block The ABSOLUTE VALUE Block is a block where an absolute value of a function is needed. An absolute value is the distance away from 0 (in either direction) that number is. For example 3 and -3 both have an absolute value of 3.
BBC micro:bit microbit _maths_maximum
MAXIMUM Block The MAXIMUM Block finds the maximum of two values you insert into each side of this function.
BBC micro:bit microbit maths_minimum
MINIMUM Block The MINIMUM Block finds the minimum of two values you insert into each side of this function.
BBC micro:bit microbit _maths_pick_random_to_number
RANDOM VALUE Block The RANDOM VALUE Block picks a random value between two set parameters. You can set the parameter by typing a number into the right hand side of this block.
 

VARIABLES BLOCKS

SET ITEM TO Block The SET ITEM TO Block assigns the value of the selected variable to a value. This value could be a fixed numeric value or that of another variable.
BBC micro:bit microbit _variables_item
VARIABLE VALUE Block The VARIABLE VALUE Block gets the current value of a variable you choose from a drop-down menu.
BBC micro:bit microbit _variables_change_item_by
CHANGE VARIABLE VALUE Block The CHANGE VARIABLE VALUE Block gets the current value of a variable you choose from a drop-down menu and enables you to change it by a number inserted into the right side of the block.

GAME BLOCKS

BBC micro:bit microbit game_create_sprite
CREATE SPRITE Block The CREATE SPRITE (GAME) Block creates a LED sprite (single LED) to show at the specified coordinates in the function.
BBC micro:bit microbit _game_move
MOVE Block The MOVE (GAME) Block moves the LED sprite by a specified number of pixels (LED rows/columns).
BBC micro:bit microbit game_turn
TURN Block The TURN (GAME) Block rotates the LED sprite by a certain number of degrees.
BBC micro:bit microbit game_change
CHANGE Block The CHANGE Block will change any of the four input readings (x, y, direction and brightness) of a variable by a specified number.
BBC micro:bit microbit game_set
SET Block The SET Block will set any of the four input readings (x, y, direction and brightness) of a variable by a specified number.
BBC micro:bit microbit _game_touching
REPORTS Block The REPORTS Block will report the x or y position of a specified variable. This can be either a LED sprite or the brightness of the LED sprite currently on the LED matrix screen.
BBC micro:bit microbit _game_touching
TOUCHING Block This TOUCHING Block Block reports if the sprite is touching a specified sprite. This can be useful in games that involve or prevent contact with other LED sprites.
BBC micro:bit microbit _game_touching_edge
TOUCHING EDGE Block The TOUCHING EDGE Block reports as true if the sprite is touching an edge of the LED matrix display.
BBC micro:bit microbit _game_if_on_edge_bounce
IF ON EDGE, BOUNCE Block The IF ON EDGE, BOUNCE Block will bounce the LED sprite from the edge if the LED sprite comes in contact with any of the edges of the LED display matrix.
BBC micro:bit microbit game_change_score_by
CHANGE SCORE BY Block The CHANGE SCORE BY Block adds the score to a game by a specified amount.
BBC micro:bit microbit _game_score
SCORE Block The SCORE Block displays the current score of a game on the LED matrix display when used with the SHOW NUMBER function. It can be used to change different parameters of the game if the player reaches a certain score.
BBC micro:bit microbit game_start_countdown_of
START COUNTDOWN Block The START COUNDOWN Block starts a countdown (in milliseconds) when this function is run.
BBC micro:bit microbit game_game_over
GAME OVER Block The GAME OVER Block shows 'GAME OVER' scrolling over and over again until the function is interrupted. You can use this in correspondence with the 'SHOW STRING' and 'ADD TEXT' Blocks to show an opposite ‘YOU WIN’ text when the player wins/looses.

MUSIC BLOCKS

BBC micro:bit microbit _music_play_tone
PLAY TONE Block The PLAY TONE Block plays a tone (Notes A to G) at a set frequency (Hz) through pin P0 for a fraction of a beat (in ms). This can be used with an external device such as a piezo to play musical tones.
BBC micro:bit microbit _music_ring_tone
RING TONE Block The RING TONE Block rings a tone (in Hz) for a set amount of time.
BBC micro:bit microbit music_rest
REST Block The REST Block enables the BBC micro:bit to rest for a specified amount of time (measured in ms) as a fraction of a beat (1 – 1/16 beat).
BBC micro:bit microbit music_tempo
TEMPO Block This TEMPO Block sets the tempo (speed of a musical beat) of a variable measured in beats per minute (bpm).
BBC micro:bit microbit _music_set_tempo_to
SET TEMPO Block This SET TEMPO Block overrides the previous instructions and sets the tempo of a period of music (in bpm) with a number block.
BBC micro:bit microbit music_change_tempo_by
CHANGE TEMPO Block This CHANGE TEMPO Block changes the current tempo currently running on the BBC micro:bit and changes it to the numerical value in this function.

BBC micro:bit BLOCKS

BASIC BLOCKS

BBC micro:bit microbit _show_leds
SHOW LEDs Block The SHOW LEDs Block is used to display an image on the display. If a box is tocked then the corresponding LED will be lit up.
BBC micro:bit microbit show_leds
CLEAR SCREEN Block The CLEAR SCREEN Block (BASIC) clears the screen of LEDs currently displayed on the LED display matrix.
BBC micro:bit microbit _show_string
SHOW STRING Block The SHOW STRING Block is used to show a string of characters on the LED display. Text will scroll across the display (from left to right) until all the characters have been shown.
BBC micro:bit microbit pause
PAUSE Block The PAUSE block pauses the programming on the BBC micro:bit for a specified amount of time before running the next set of commands. The time interval is measured in milliseconds (ms) (1000th of a second).
BBC micro:bit microbit show_number
SHOW NUMBER Block The SHOW NUMBER block displays a number (0-9) on the LED matrix of the BBC micro:bit.
 

LED BLOCKS

BBC micro:bit microbit _led_plot
PLOT Block The PLOT Block turns on a LED on the LED screen. You can specify which LED using the x and y coordinates in each of the number blocks.
BBC micro:bit microbit _led_unplot
UNPLOT Block The UNPLOT Block turns a LED currently on the screen, off. This can be used in conjunction with the PLOT (LED) function.
BBC micro:bit microbit led_brightness
BRIGHTNESS Block The BRIGHTNESS Block can be added to the end of a command to specify the current brightness of the LED display.
BBC micro:bit microbit _led_set_brightness
SET BRIGHTNESS TO Block The SET BRIGHTNESS TO Block sets the brightness of the LED screen. Full brightness has a value of 255, so 127 is around 50% brightness. If the brightness is more than 100%, the code automatically sets the brightness to 100%.
BBC micro:bit microbit _led_plot_bar_graph
STOP ANIMATION Block The STOP ANIMATION Block stops the current animation that is playing on the BBC micro:bit.
BBC micro:bit microbit led_plot_bargraph
PLOT BAR GRAPH Block The PLOT BAR GRAPH Block plots a bar graph on the LED display. The bar graph can be from empty (‘0’) to filling the whole LED display ('1023').

IMAGES BLOCKS

microbit_led_show_image_block
SHOW IMAGE Block The SHOW IMAGE Block (IMAGES) shows an image on the LED display matrix followed by a 400ms pause. The offset is the number for the horizontal starting point of an image: '0' to display the first image, '5' for the second image, '10' for the third frame and so on.
microbit_images_scroll_image
SCROLL IMAGE Block The SCROLL IMAGE Block scrolls the frames within an image on the LED display. To jump from one image to another, use the offset values of '5' to jump to the right and '-5' to jump to the left. The interval time (in ms) controls the speed of the scrolling. The larger the number, the slower the scroll.
microbit_images_create_image
CREATE IMAGE Block The CREATE IMAGE Block creates an image on the LED display when the image boxes are checked.
microbit_images_create_big_image
CREATE BIG IMAGE Block The CREATE BIG IMAGE Block creates a larger image on the LED display when the image boxes are checked.

BBC micro:bit INPUT BLOCKS

microbit_inputs_on_pin_p0_do
ON PIN (P0*) PRESSED DO Block Commands placed within the ON PIN (P0*) PRESSED DO Block will run when the user holds the GND pin with one hand and presses the selected pin with the other hand.
microbit_inputs_button_a_pressed
ON BUTTON (A*) PRESSED DO Block Commands placed within the ON BUTTON (A*) PRESSED DO Block will run whenever the selected button or buttons are pressed.
microbit_inputs_button_a_is_pressed
BUTTON IS PRESSED Block The BUTTON IS PRESSED Block gets the state of an input button. The BBC micro:bit has two input buttons: A and B.
microbit_inputs_button_compass_heading
COMPASS HEADING Block The COMPASS HEADING Block returns the current heading (in o) for the BBC micro:bit and stores it in the 'degrees' variable.
microbit_inputs_button_temperature
TEMPERATURE Block The TEMPERATURE Block records the ambient temperature of the surface of the BBC micro:bit using the temperature sensor inside the CPU of the BBC micro:bit. This figure won’t be as accurate if the BBC micro:bit has been running a number of calculations after a long period of time. The temperature sensor is precise but not accurate as it might return a base line temperature offset (e.g. it will return 20 degrees when the ambient temperature is actually 17 degrees.
microbit_inputs_button_temperature
ACCELERATION Block The ACCELERATION Block gets the acceleration value (milli g-force) of one of the three specified dimensions (X, Y and Z axis) from the built-in accelerometer.
microbit_game_touching
ROTATION Block The ROTATION Block gets a rotation angle in degrees inferred from the accelerometer readings.
microbit_input_light_level
LIGHT LEVEL Block The LIGHT LEVEL Block detects the current light level and displays it as a number between 0 (dark) and 255 (bright).
microbit_show_ledsmicrobit_input_on_shake_drop_down
ON (COMMAND) DO Block The ON (Command) DO Block has a drop down list of commands. ON SHAKE uses the built-in accelerometer to detect when the BBC micro:bit is shaken, if the BBC logo on the BBC micro:bit is facing up or down. ON LOGO UP registers an event handler that will execute whenever the LED screen is perpendicular to the ground and the BBC micro:bit logo is above the LED screen. ON LOG DOWN registers an event handler that will execute whenever the LED screen is perpendicular to the ground and the BBC micro:bit logo is below the LED screen. ON SCREEN UP registers an event handler that will execute whenever the LED screen is facing the ceiling/sky. ON SCREEN DOWN registers an event handler that will execute whenever the LED screen is facing the floor.
microbit_inputs_magnetic_force
MAGNET FORCE Block The MAGNET FORCE Block gets the magnetic force (micro Teslas) from the magnetometer and returns a number in one of three specified dimensions (x, y and z).
microbit_inputs_running_time
RUNNING TIME Block The RUNNING TIME Block gets the number of milliseconds elapsed since the script began and displays it as a scrolling number on the LED matrix. 1,000 milliseconds = 1 second.

PINS BLOCKS

microbit_pins_digital_read_write_pin
DIGITAL READ PIN (0,1) TO PIN (P0*) Block The DIGITAL READ PIN (0,1) (P0*) Block reads the digital voltage on the selected pin and returns a '0' if there is as 'low' voltage or a '1' if it is a 'high' voltage. (A 'low' voltage is anything below 0.8 Volts. A 'high' voltage is anything above 1.6 Volts).
microbit_pins_digital_read_write_pin
DIGITAL WRITE (0,1) TO PIN (P0*) Block The DIGITAL WRITE (0, 1) TO PIN (P0*) Block writes either a '0' (a low voltage) or a '1' (a high voltage) to the specified pin. To change the value that is written to the pin, select the box that has a '1' in it and edit to a '1' or '0' as required.
microbit_pins_analog_read_pin
ANALOG READ PIN (P0*) Block The ANALOG READ PIN (P0*) Block reads the analog (variable) voltage on pin P0, P1 or P2 (depending on which is selected) and returns a number between 0 and 1024 depending on the level of the voltage present on that pin.
microbit_pins_analog_write_to_pin
ANALOG WRITE (1024) TO PIN (P0*) Block The ANALOG WRITE (1024) TO PIN (P0*) Block writes an analog value (variable voltage) to in P0, P1 or P2 (depending on which is selected). The voltage on that pin will be set to a level defined by the size of the number written where 0 = 0V and 1024 = 3.3V.*SELECTING THE PIN/BUTTON The 'drop down' arrow next to the default pin 'P0' or button 'A' allows the pin/button which the command write/reads to be changed.
microbit_pins_analog_set_period_to_pin
ANALOG SET PERIOD Block The ANALOG SET PERIOD Block configures the period of the Pulse Width Modulation (PWM) on the specified analog pin (P0, P1 or P2). Before putting in this function, the pin you want to change should be set as analog.
microbit_pins_servo_write_to_pin
SERVO WRITE PIN Block The SERVO WRITE PIN Block writes a value to the servo on to the specified pin (P0, P1, P2), controlling the shaft accordingly:
  • On a standard servo, this will set the angle of the shaft (in degrees), moving the shaft to that orientation.
  • On a continuous rotation servo, this will set the speed of the servo (with 0 being full-speed in one direction, 180 being full speed in the other, and a value near 90 being no movement).
microbit_pins_servo_set_pulse_to_pin
SERVO SET PULSE Block The SERVO SET PULSE Block configures the pin (P0, P1 or P2) as an analog/PWM output, configures the period to be 20ms and sets the pulse width based on the value it is given.
microbit_pins_map
MAP Block The MAP Block (PINS) re-maps a number from one range to another. That is, a value of from low would get mapped to to low, a value of from high to to high, values in-between to values in-between, etc. Does not constrain values to within the range, because out-of-range values are sometimes intended and useful. The math-clamp function can be used either before or after this function, if limits to the ranges are desired.

DEVICES Blocks

microbit_devices_tell_camera_take_photo
TELL CAMERA TO Block The TELL CAMERA TO Block adds an external camera capability when an external camera is attached to the BBC micro:bit. This command can be to either a smartphone's camera or an externally connected camera. The camera commands include taking a photo, start/stop video capture, toggling front/rear, launch photo/video mode and stop/video/photo mode.
microbit_devices_raise_alert
RAISE ALERT TO Block The RAISE ALERT TO Block raises an alert in the BBC micro:bit and orders the BBC micro:bit to do an external action. The options in the alert include telling the BBC micro:bit to 'display toast', vibrate, play a sound or ringtone, find my phone and ring an alarm.
microbit_device_tell_remote_controlmicrobit_device_tell_remote_control_drop_down
TELL REMOTE CONTROL TO Block The TELL REMOTE CONTROL TO Block adds a command to an external supported remote control so you can control and tell the remote control what to do when this command is triggered. The options include telling the remote control to 'play', 'pause', 'stop', 'next/previous track', forward, rewind, volume up and volume down.
microbit_device_on_notifiedmicrobit_device_on_notified_drop_down
ON NOTIFIED Block The ON NOTIFIED Block runs a command when BBC micro:bit receives the selected event from a connected device. The available commands are 'incoming call', 'incoming message', 'orientation landscape', 'orientation portrait', 'shaken', 'display off' and 'display on'.
microbit_device_signal_strength
SIGNAL STRENGTH Block The SIGNAL STRENGTH Block returns the signal strength reported by the paired device from 0 (no signal) to 4 (full strength).
microbit_device_on_signal_strength_changed
ON SIGNAL STRENGTH CHANGED Block The ON SIGNAL STRENGTH CHANGED Block registers code to run when the signal strength of the paired device changes.

Leave a comment

All comments are moderated before being published