Skip to content

​​This repository contains three MATLAB LiveScripts and starter Simulink models that teach students how to use Stateflow with the BBC micro:bit. Each exercise covers a fun, hands-on project that demonstrates key Stateflow concepts and embedded programming techniques.​

License

Notifications You must be signed in to change notification settings

mathworks/Learn-Stateflow-with-Micro-bit

Repository files navigation

Learn Stateflow with the BBC Micro:bit

Open in MATLAB Online

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.

Setup

Required MathWorks® Products (https://www.mathworks.com)

Requires MATLAB release R2024b or newer

Required Hardware

  • BBC micro:bit board, any version will work
  • USB type A to Micro-B cable

Installation

  1. Clone or download this repository to your local machine and open in MATLAB
  2. Install the Simulink Support Package for BBC micro:bit in MATLAB.
  3. Connect your BBC micro:bit to your computer via USB.

Instructions

  1. Open the Dice, RPS, or Steps ".mlx" live script to follow the step by step instructions
  2. Modify and run the models as guided in the LiveScripts.
  3. If needed, completed versions of the models exist in the Finished Models folder

Exercises

Digital Dice

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.

Step Tracker

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.

Rock Paper Scissors

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.

License

The license is available in the License.txt file in this GitHub repository.

Community Support

MATLAB Central

Copyright 2025 The MathWorks, Inc.

About

​​This repository contains three MATLAB LiveScripts and starter Simulink models that teach students how to use Stateflow with the BBC micro:bit. Each exercise covers a fun, hands-on project that demonstrates key Stateflow concepts and embedded programming techniques.​

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published