Theory
📟⚙️ 2. Building blocks of Micro: bit
Basic Block: Provide access to basic micro: bit functionality:
![]() |
💡 Shows number on LED screen; slides left for multiple digits. 🔄 |
![]() |
🖼️ Displays picture on LED screen.
|
![]() |
🖼️ Shows the selected icon on the LED screen. |
![]() |
📜 Shows a string on the LED screen. It will scroll to left if it’s bigger than the screen. |
![]() |
💡 Turns off all the LED lights on the LED screen. |
![]() |
⏩ Keeps running part of a program in the background. |
![]() |
🏁 An event that runs when the program starts. |
![]() |
⏸️ Pauses the program for the number of milliseconds you say. You can use this function to slow your program down. |
![]() |
➡️ Shows the selected arrow on the LED screen. |
Input Block: Events and data from sensors:
![]() |
⮚ 🎮 Event handler activates on button press.
⮚ 🅰️ or 🅱️: Press and release within 1 sec; 🅰️ and 🅱️ together: press both, release one within 1.5 sec. |
![]() |
⮚ 🔄 Start event handler: Runs on specific gestures.
⮚ 🤲 Gesture detection: Triggers actions, such as shaking the micro: bit. |
![]() |
⮚ ⚡️👆 Event handler activates when pin 0, 1, or 2 is touched with GND, released within 1 second.
⮚ 🖱️ Click pins on screen in web browser; completing circuit feels like being a big wire! |
![]() |
🔍 Checks if button A or B is currently pressed on the micro: bit. |
![]() |
📊 Retrieves acceleration values (milli g-force) in x, y, z dimensions or combined force. |
![]() |
🔌 Hold GND pin with one hand and touch pin 0, 1, or 2 with other to complete circuit safely, allowing electricity flow through body. |
![]() |
🔆 Measures light level from darkness (0) to bright light (255) using micro: bit’s LED screen; initially displays 0, then shows real light level after activating the light sensor. |
![]() |
🧭📐 Micro: bit uses magnetometer chip to measure compass heading from 0 to 359 degrees, indicating north, east, south, and west directions. |
![]() |
🌡️ Uses micro: bit to find nearby temperature by measuring computer chip heat in Celsius. |
![]() |
✋🔍 Checks for gesture detection. |
![]() |
🎤🔊 Runs code when microphone detects sound. |
![]() |
⚙️ Runs some code when micro: bit logo is pressed, touched, or released. |
![]() |
🖲️ Checks if micro: bit logo is currently pressed. |
![]() |
🎤 Finds sound level heard by microphone. |
![]() |
🔄 Finds tilt direction of micro: bit. |
![]() |
🔍 Finds magnetic force in one direction. |
![]() |
⏱️ Finds program duration in milliseconds. |
![]() |
⏲️ Finds program duration in microseconds. |
![]() |
🧭 Runs compass calibration sequence. |
![]() |
🔌👋 Starts event handler when releasing pin 0, 1, or 2 together with GND; in browser, click and release pins instead; completing a circuit when touching pins while holding GND. |
![]() |
🚀 Configures micro: bit acceleration sensor for measuring speed changes, whether high or low. |
![]() |
🔊📏 Determines the sound level threshold for detection on your board. |
Music Block: Generation of music tones:
![]() |
🎵 Plays a short melody of notes composed in a string. |
![]() |
🎶 Plays a musical tone through pin P0 of the micro: bit for as long as you say. |
![]() |
🔊 Plays a musical tone through pin P0 with the pitch as high or low as you say. The tone will keep playing until you tell it not to. |
![]() |
🔇 Rest (plays no sound) through pin P0 for the amount of time you say. |
![]() |
🔉 Sets the volume for the sound synthesizer. |
![]() |
🔊 Gets the current volume level of the sound synthesizer. |
![]() |
⏹️ Stops all the sounds that are playing right now and any others waiting to play. |
![]() |
🎵 Makes the tempo (speed of a piece of music) faster or slower by the amount you say. |
![]() |
🎶 Makes the tempo (speed of a piece of music) as fast or slow as you say. |
![]() |
⏰ Returns the duration of a beat in milliseconds |
![]() |
🎶 Finds the tempo (speed of a piece of music). |
![]() |
🎵 Begins playing a musical melody through pin P0 of the micro: bit. |
![]() |
⏹️ Stops playing a musical melody. |
![]() |
🎵 Raises events for melodies or music events. |
![]() |
🎵 Plays a sound that is generated from a sound expression. |
![]() |
🎵 Plays a sound that is generated from a sound expression. |
![]() |
🔊 Creates a sound expression string for a sound effect. |
![]() |
🔊 Enables the speaker on the micro: bit to play music and sounds. |
Led Blocks: Control of the LED screens:
![]() |
🔆 Turns on the LED light at specified x, y coordinates on the LED screen. |
![]() |
🔄 Toggles a LED light on the LED screen at specified x, y coordinates. |
![]() |
🚫 Turns off the LED light at specified x, y coordinates on the LED screen. |
![]() |
🔄 Toggles a LED light on the LED screen at specified x, y coordinates. |
![]() |
🔍 Finds whether the LED at specified x, y coordinates on the LED screen is on or off. |
![]() |
📊 Displays a bar graph for a number value. |
![]() |
💡 Turns on a LED light with specific brightness at specified x, y coordinates on the LED screen. |
![]() |
🔆 Reads the brightness of a LED at specified x, y coordinates on the LED screen. |
![]() |
💡🔍 Finds the brightness of the LED screen when turned on. |
![]() |
🔛🔇 Disables the LED |
![]() |
⏹️ Stops the playing animation and any waiting animations. |
![]() |
🖥️ Sets the display mode to either black and white or grayscale for rendering LEDs. |
Loops Blocks: Loops and repetition:
![]() |
🔄 Runs part of the program the number of times you say. |
![]() |
🔁 Repeats code while a Boolean condition is true. |
![]() |
🔂 Runs part of the program the number of times you say using an index variable. |
![]() |
📜 Runs part of the program for each element in a list. |
![]() |
⏱️ Runs part of the program in a loop continuously at a time interval. |
![]() |
🛑 Breaks out of the current loop and continue the program. |
![]() |
↪️ Skips the rest of the code in a loop and start the loop again. |
Logic Blocks: Logic operators and constants:
![]() |
🔄 Runs code depending on Boolean condition is true |
![]() |
🔄 Runs code depending on Boolean condition is true or false |
![]() |
🔍 The blocks represent comparison operators yielding Boolean values. Most comparisons involve numbers. |
![]() |
🔗 Conjunction (A and B): A and B evaluates to true if both A and B are true. |
![]() |
🔗 Negation (Not A): not A evaluates to the opposite of A. |
![]() ![]() |
✅ These blocks represent true and false Boolean values, pluggable wherever expected. |
Variable Blocks: Creates variables and stores variables:
![]() |
🔢 Increases variable value by some amount. |
![]() |
📝 Sets variable to store number or string. |