Smileys Using Micro:bit | Amazing Coding Activity in 8 Steps
Block-Based Coding with MakeCode + MicroPython : Overview
The BBC micro:bit is a pocket-sized computer with a 5×5 grid of LEDs that students can program to display images, animations, and expressions. In this project, students build a small program that shows different smiley faces — happy, sad, surprised, and winking — in response to button presses and gestures. Along the way, students learn about the LED matrix, event-driven programming, and how the exact same logic can be written as drag-and-drop blocks or as real text-based code.
The BBC micro:bit board — LED matrix, buttons A and B, USB port, and battery connector.
Materials Required
- BBC micro:bit board (v1 or v2)
- Micro-USB cable
- Computer or laptop with a web browser
- Internet connection (to access the MakeCode editor)
- Optional: AAA battery pack (to run the program without a computer)
Learning Objectives
- Understand event-driven programming (button press, shake, button combinations).
- Represent images on a 5×5 LED grid using coordinates.
- Use block-based coding and connect it to equivalent text-based code.
- Read and write simple MicroPython syntax.
- Use loops and pauses to create timed sequences.
- Develop logical and computational thinking.
Step-by-Step Instructions
- Go to makecode.microbit.org and start a New Project.
- Open the LED Screen drawer and drag out a “show leds” block.
- Click the grid squares to draw a happy face pattern.
- From the Input drawer, drag “on button A pressed” and place the happy-face block inside it.
- Repeat for Button B with a sad face, and for “on shake” with a surprised face.
- Add an “on button A+B pressed” block for a winking face.
- Connect the micro:bit with the USB cable and download the program to test it.
- Switch the editor to the JavaScript or Python view to see the same logic as real code.
Block-Based Coding Logic
Below is the block logic in plain pseudocode, followed by a rendering of what the actual MakeCode blocks look like.
MakeCode blocks: each event block (orange/purple) triggers a display block (blue) on the LED matrix.
The four LED matrix patterns the program displays: happy, sad, surprised, and wink.
Detailed Code — MakeCode JavaScript
MakeCode can show the exact same program as JavaScript. This is the same logic as the blocks above, written as text:
Explanation, line by line:
Detailed Code — MicroPython
The same program written in MicroPython, the text-based language most micro:bit classrooms move on to after blocks:
Explanation, line by line:
Expected Output
- Pressing Button A displays a happy face.
- Pressing Button B displays a sad face.
- Shaking the board displays a surprised face.
- Pressing both buttons together displays a wink.
- Without any input, the board can loop through a default animation (happy face blinking on and off).
STEM Concepts Covered
- Computer Science
- Event-driven programming
- Coordinate grids and pixel art
- Conditional logic
- Loops and timing (pause/sleep)
- Hardware input: buttons and accelerometer
Real-World Applications
- Wearable devices that display status icons
- Simple robots with expressive “faces”
- Alert and notification systems
- Accessible communication devices
- Embedded systems in appliances and toys
Tips for Students
- Test each face individually before combining all four events.
- Try designing your own custom face — the grid is a coordinate system, so any pattern is possible.
- Add basic.showIcon() as a shortcut for common built-in icons instead of drawing every LED manually.
- Add music.playTone() or a short melody alongside each face for extra feedback.
- Try switching between the Blocks, JavaScript, and Python views in MakeCode to see how the same logic looks in each.
Frequently Asked Questions (FAQs)
- Do I need to buy anything besides the micro:bit?
No — a micro-USB cable and a computer with a browser are enough to program and test it.
- What is the difference between MakeCode blocks and MicroPython?
They produce the same result. Blocks are easier for beginners; MicroPython is closer to real-world programming languages like Python.
- Can I make more than four faces?
Yes — add more event blocks (e.g., “on logo touched” on a v2 board) and design a new LED pattern for each.
- Why does the loop need a pause?
Without a short pause, the loop would run so fast it wastes power and can make button presses harder to detect reliably.
- Can this run without a computer connected?
Yes — once the program is downloaded to the micro:bit, an external battery pack lets it run on its own.
Conclusion
Creating different emoticons on the micro:bit is a hands-on way to learn event-driven programming, coordinate-based image design, and the relationship between block-based and text-based coding. Because the same project can be built with blocks, JavaScript, or MicroPython, students get to see how visual coding concepts map directly onto real programming syntax.
This project also opens the door to further exploration — adding sounds, designing entirely new expressions, connecting external LEDs, or using the accelerometer for more gesture-based interactions. Practicing with the micro:bit builds a strong foundation for moving into more advanced physical computing and Python programming.



















