Make Code Micro Bit: Why Block Coding Still Matters
- 01. How to Make Code for micro:bit: A Complete Starter Guide
- 02. What Is the micro:bit and Why Code It?
- 03. Setting Up Your MakeCode Environment
- 04. Your First micro:bit Code Project: Hello World LED
- 05. Block-Based Code Instructions
- 06. Python Code Equivalent
- 07. Essential MakeCode Blocks for Beginners
- 08. Five Beginner micro:bit Projects Beyond Basics
- 09. 1. Digital Dice Roller
- 10. 2. Step Counter (Pedometer)
- 11. 3. Temperature Alert System
- 12. 4. Compass Direction Finder
- 13. 5. Reaction Time Game
- 14. Advanced Techniques: Variables, Loops, and Conditionals
- 15. Variables: Storing Data
- 16. Loops: Repeating Code
- 17. Conditionals: Making Decisions
- 18. Troubleshooting Common micro:bit Coding Issues
- 19. Resources for Continued micro:bit Learning
How to Make Code for micro:bit: A Complete Starter Guide
To make code for micro:bit, you access the official MakeCode editor at makecode.microbit.org, select either the block-based or JavaScript/Python view, drag commands onto the workspace or type code, and click the Download button to save the .hex file onto your micro:bit device via USB. This process takes less than five minutes for beginners and enables immediate hands-on learning with the device's LED matrix, buttons, and sensors .
What Is the micro:bit and Why Code It?
The micro:bit is a pocket-sized programmable computer designed by the BBC in 2016 for STEM education, featuring a 5x5 LED matrix, two programmable buttons, a thermometer, an accelerometer, a magnetometer, and Bluetooth Low Energy connectivity . Over 10 million micro:bit devices have been distributed globally since its launch, with 90% of UK schools now incorporating it into their computer science curriculum . The device runs on an ARM Cortex-M4 processor at 164 MHz and includes 256 KB of flash memory, making it powerful enough for beginner robotics projects while remaining accessible to learners aged 10-18.
Code for micro:bit enables students to build real-world projects like gesture-controlled games, weather stations, step counters, and even simple robots. The platform supports multiple programming languages including block-based MakeCode, Python (MicroPython), and JavaScript, allowing learners to progress from visual coding to text-based programming seamlessly.
Setting Up Your MakeCode Environment
Before writing your first micro:bit code, you must set up the MakeCode editor environment. Follow these exact steps:
- Open your web browser and navigate to makecode.microbit.org
- Click "New Project" and name it (e.g., "MyFirstMicrobit")
- Choose between "Blocks" (visual drag-and-drop) or "JavaScript"/"Python" (text-based) view using the toggle button
- Connect your micro:bit to your computer using a micro-USB cable
- Click the "Download" button at the bottom of the editor to save the .hex file
- Drag the downloaded file onto the "MICROBIT" drive that appears on your computer
- The micro:bit's LED matrix will flash briefly, confirming successful code upload
The MakeCode editor auto-saves your projects to the cloud, so you can resume work from any device with internet access. As of March 2025, the platform has over 2.3 million active users and supports 42 languages .
Your First micro:bit Code Project: Hello World LED
Let's create your first functional micro:bit project that displays "Hello" on the LED matrix. This project teaches the fundamental concepts of LED programming, event handling, and code deployment.
Block-Based Code Instructions
- In MakeCode, click "Basic" in the left sidebar
- Drag the "show string" block onto the workspace
- Type "Hello" in the text field
- Drag this block inside the "on start" block (already present)
- Click "Download" and transfer the file to your micro:bit
- Your micro:bit will now display "Hello" scrolling across the LED matrix
Python Code Equivalent
For text-based programmers, the equivalent MicroPython code is:
from microbit import *
while True:
display.scroll("Hello")
sleep(1000)
This code imports the micro:bit library, creates an infinite loop, scrolls "Hello" across the display, and waits one second between repetitions. The while True loop ensures continuous execution, which is essential for interactive projects.
Essential MakeCode Blocks for Beginners
Understanding the core blocks in MakeCode is critical for building more complex micro:bit projects. These fundamental blocks form the foundation of nearly all beginner projects:
| Category | Block Name | Function | Typical Use Case |
|---|---|---|---|
| Basic | show LED | Lights specific LED pixels | Creating custom icons or patterns |
| Basic | show string | Scrolls text across LEDs | Displaying messages or names |
| Input | on button A pressed | Triggers code when Button A is pressed | Game controls, menu navigation |
| Input | on shake | Triggers code when micro:bit is shaken | Step counters, motion detection |
| Sensors | temperature | Returns current temperature in °C | Weather stations, climate monitoring |
| Sensors | accelerometer (gravity) | Measures tilt and motion | Gesture recognition, balance games |
| Loops | forever | Repeats code continuously | Main program loop, real-time monitoring |
| Logic | if-then | Executes code only if condition is true | Decision-making, conditional logic |
Mastering these blocks enables you to create projects ranging from simple dice rollers to complex environmental sensors that log temperature and humidity data over time.
Five Beginner micro:bit Projects Beyond Basics
Once you understand the fundamentals, challenge yourself with these five projects that build real engineering skills while remaining accessible to learners aged 10-18.
1. Digital Dice Roller
Build a random number generator that displays 1-6 on the LED matrix when shaken. This project teaches randomization logic, event handling, and conditional display logic.
- Use "on shake" block from Input category
- Add "pick random 1 to 6" block from Math category
- Use "show number" block to display the result
- Add a short delay (200ms) to prevent multiple triggers
When you shake your micro:bit, it randomly selects a number and displays it as a die face pattern using LED pixels.
2. Step Counter (Pedometer)
Create a wearable device that counts steps using the accelerometer. This project demonstrates sensor calibration and real-world data collection.
- Create a variable called "steps"
- Use "on shake" to increment the variable by 1
- Display the step count on Button A press
- Reset steps to 0 on Button B press
According to a 2024 study by the National STEM Education Consortium, students who built wearable sensors showed 37% higher engagement in physics class compared to traditional textbook learning .
3. Temperature Alert System
Build a device that displays a heart icon when temperature exceeds 25°C and a snowflake when below 15°C. This project teaches threshold logic and environmental monitoring.
from microbit import *
while True:
temp = temperature()
if temp > 25:
display.show(Image.HEART)
elif temp < 15:
display.show(Image.SNOWFLAKE)
else:
display.show(temp)
sleep(1000)
4. Compass Direction Finder
Use the magnetometer to display N, E, S, or W based on which direction the micro:bit faces. This project introduces magnetic field sensing and cardinal direction logic.
5. Reaction Time Game
Create a game where a random LED lights up, and the player must press Button A as quickly as possible. The micro:bit displays the reaction time in milliseconds. This project teaches timer functions and user interaction design.
Advanced Techniques: Variables, Loops, and Conditionals
To create sophisticated micro:bit projects, you must master three core programming concepts: variables, loops, and conditionals. These programming fundamentals are universal across all languages and are essential for any software development career.
Variables: Storing Data
Variables store values that can change during program execution. In MakeCode, create a variable by clicking "Variables" → "Make a Variable" → name it (e.g., "score"). You can then use "set score to 0", "change score by 1", and "show score" blocks.
Example: A scoring system for a game where points increase when Button A is pressed and decrease when Button B is pressed.
Loops: Repeating Code
Loops execute code multiple times without duplication. The "forever" loop runs continuously, while "repeat 10 times" executes a block exactly 10 times. Use loops for continuous monitoring like sensor reading or animation sequences.
Conditionals: Making Decisions
Conditionals execute code only when specific conditions are met. The "if-then-else" structure allows your micro:bit to respond differently based on sensor input, button presses, or variable values.
if input.button_is_pressed(Button.A):
display.show(Image.HEART)
else:
display.show(Image.SKULL)
This code displays a heart when Button A is pressed and a skull otherwise, demonstrating binary decision logic.
Troubleshooting Common micro:bit Coding Issues
Even experienced educators encounter issues when coding micro:bit. Here are the most common problems and their solutions based on data from 50,000+ MakeCode support tickets in 2024 :
| Problem | Cause | Solution |
|---|---|---|
| Code won't download | USB cable is charge-only | Use a data-capable micro-USB cable |
| LED matrix stays blank | Code not properly deployed | Re-download .hex file and verify drive appears |
| Button doesn't respond | Missing "on button pressed" block | Add event handler from Input category |
| Temperature reads incorrectly | Processor heat interference | Wait 30 seconds after powering on |
| Project crashes randomly | Infinite loop without delay | Add sleep inside forever loops |
If your micro:bit still doesn't work after troubleshooting, try a factory reset by holding both buttons while connecting USB, then releasing when the triangle appears.
Resources for Continued micro:bit Learning
Expand your knowledge with these trusted resources aligned with curriculum standards for grades 5-12:
- Official MakeCode Projects Gallery: 2,400+ community-created projects with source code
- micro:bit Educational Foundation Lesson Plans: 150+ NGSS-aligned activities
- TheStempedia.com micro:bit Course: Step-by-step video tutorials for educators
- Python for micro:bit Documentation: Complete MicroPython reference guide
- STEM Challenge Cards: 50 printable project prompts for classroom use
According to the 2025 STEM Education Report, schools using micro:bit reported a 42% increase in student interest in engineering careers and a 28% improvement in coding assessment scores .
Everything you need to know about Make Code Micro Bit Why Block Coding Still Matters
How do I make code for micro:bit?
To make code for micro:bit, visit makecode.microbit.org, create a new project, drag blocks or write code, click Download, and transfer the .hex file to your micro:bit via USB. The entire process takes under five minutes and requires no software installation .
What programming languages work with micro:bit?
micro:bit supports three main programming languages: Microsoft MakeCode (block-based and JavaScript), MicroPython (Python), and Scratch (via extension). MakeCode is recommended for beginners, while Python is ideal for learners transitioning to text-based coding .
Do I need special hardware to code micro:bit?
No special hardware is required beyond the micro:bit board itself and a micro-USB cable for connectivity. A computer with internet access is needed for the MakeCode editor, though offline editors are available for classroom environments without internet .
How long does it take to learn micro:bit coding?
Beginners can create their first working project in 15-30 minutes. Mastery of core concepts (variables, loops, conditionals, sensors) typically takes 4-6 weeks of regular practice. The micro:bit Educational Foundation recommends 20 hours of guided instruction for comprehensive curriculum coverage .
Can I use micro:bit without a computer?
Yes, the micro:bit mobile app (iOS and Android) allows coding via Bluetooth without a computer. However, the web-based MakeCode editor offers more features and is recommended for initial learning. The mobile app supports 85% of MakeCode blocks .