This repository provides three hands-on MATLAB LiveScripts and starter Simulink models, designed to teach students how to use Stateflow for embedded logic and interactive applications on the BBC micro:bit. Each exercise walks through the creation of a real-world project—from a digital dice roller to a step counter and a rock-paper-scissors game—while demonstrating key Stateflow concepts and embedded programming skills.
Required MathWorks® Products (https://www.mathworks.com)
Requires MATLAB release R2024b or newer
- MATLAB
- Simulink
- Stateflow®
- Embedded Coder®
- Fixed-Point Designer™
- Simulink Coder Support Package for BBC micro:bit Board
- BBC micro:bit board, any version will work
- USB type A to Micro-B cable
- Clone or download this repository to your local machine and open in MATLAB
- Install the Simulink Support Package for BBC micro:bit in MATLAB.
- Connect your BBC micro:bit to your computer via USB.
- Open the Dice, RPS, or Steps ".mlx" live script to follow the step by step instructions
- Modify and run the models as guided in the LiveScripts.
- If needed, completed versions of the models exist in the Finished Models folder
LiveScript: Dice_HW_Instructions.mlx
Simulink Model: Dice_HW_start_2025.slx
Description: Create a digital dice roller. Press a button to generate and display a random number (1–6) on the micro:bit’s LED matrix.
LiveScript: Steps_HW_Instructions.mlx
Simulink Model: Steps_HW_start_2025.slx
Description: Build a step counter using Stateflow and the micro:bit’s accelerometer. Detect shakes or steps and update the display.
LiveScript: RPS_HW_Instructions.mlx
Simulink Model: RPS_HW_start_2025.slx
Description: Design a Rock Paper Scissors game. Play against the micro:bit, with random choices and outcome display.
The license is available in the License.txt file in this GitHub repository.
Copyright 2025 The MathWorks, Inc.