micro:bit + Teachable Machine

In this activity, students explore artificial intelligence by building a sound recognition system using Teachable Machine and connecting it to a micro:bit through the Teachable Micro:Bit App.

Students begin by training a machine learning model to classify different sounds— snapping, clapping, and whistling—by collecting audio samples for each class.

Once trained, the model is exported and loaded into the Teachable Micro:Bit App, which uses the device’s microphone and camera to run the model in real time. The app sends the recognized class labels (e.g., “clap”, “snap”, “whistle”) to the micro:bit via Bluetooth, allowing students to program responses such as displaying icons, triggering sounds, or activating outputs.

Grade Levels: 3 - 12
Subject Matter: Algorithms, Artificial Intelligence (AI), Physical Computing, Programming
Concepts: Programs and Algorithms, Computing Devices and Systems, Data and Information
Standards: 3-5.PA.3, 6-8.CD.1, 6-8.CD.2, 6-8.CD.4, K-2.PA.1, K-2.PA.2, K-2.PA.3, K-2.PA.4, 3-5.PA.2, 6-8.CD.3, 6-8.PA.1, 6-8.PA.2, 6-8.PA.3, 3-5.DI.1, 6-8.DI.1, 6-8.DI.2, 3-5.CD.2, 3-5.CD.1, K-2.CD.2, 3-5.CD.3
  • Average Rating: 0.0 (0 ratings)

Activity Instructions

  1. Introduce the activity 
    • Discuss
      1. What if your computer could hear the difference between a clap and a whistle?
      2. How would we teach a computer to recognize sounds?
    • Today, you’re going to train your own AI. 
  2.  Introduce Machine Learning
    • Machine learning means teaching a computer using examples instead of step-by-step instructions.
    • Explain simply:
      1. You give examples (dataset)
      2. The computer finds patterns in the data
      3. It predicts what new inputs are
    • We’re going to teach it three sounds: snap, clap, and whistle.
  3. Train the Model
    • Guide students in Teachable Machine:
      1. Start a Sound Project
      2. Create classes:
        1. Snap
        2. Clap
        3. Whistle
      3. Record multiple samples for each
    • The more examples you give, the smarter your AI becomes. Models learn by using labeled examples of each class
  4. Train & Test
    • Now let’s see what your AI learned.
    • Students:
      1. Click Train Model
      2. Test each sound
    • Discuss:
      1. Does it recognize your sounds correctly? 
    • Optional:
      1. If it does not recognize your sounds add more data to each class and retrain.  
  5. Connect to micro:bit
    • Now we connect your AI to a real device. We will use the Teachable Micro:bit App, the app sends the detected sound label to your micro:bit.
    • Guide students to connecting teachable machine to the Teachable Micro:bit App:
      1. Export the Model to the Cloud – Within Teachable Machine, export the model to the cloud. You will receive a link that looks something like this: https://teachablemachine.withgoogle.com/models/Jgyr546VH/ 
      2. Open the Teachable Micro:Bit App – On your laptop or mobile device, open the app and click the START image button. A prompt window will appear where you need to paste the link to your Teachable Machine model.
      3. Allow Camera Access – Allow the browser to use your device camera. After loading the model, you should see a camera preview and the names of detected classes displayed below the camera window.
      4. Prepare Your Micro:Bit – Use MakeCode to write a program that allows the Micro:Bit to connect to Bluetooth UART and receive string data. You can find a sample code snippet below.
      5. Connect to the Micro:Bit – Click the robot head icon in the upper-right corner to connect to the Micro:Bit board.
      6. Control Actions – Once the connection is established, the Micro:Bit will receive class names from the app. You can then control the robot’s actions based on these messages using your Micro:Bit code.  
      7. For help see link: https://cardboard.lofirobot.com/teachable-microbit-app-info/
  6.  Program micro:bit Responses
    • Use MakeCode to program the micro:bit. The program will activate bluetooth UART on the Micro:Bit board and display received strings as text on the board display.
    • In MakeCode:
    • Use Bluetooth UART (receive string)
    • Add logic:
      1. If message = “clap” → show icon
      2. If message = “snap” → play sound
      3. If message = “whistle” → display animation
    • Walk students through creating the following code or use the provided link to share the completed code with students.
  7. Test the System
    • Download the code to your micro:bit
    • Students:
      1. Snap
      2. Clap
      3. Whistle
    • Discuss
      1. Does the micro:bit respond correctly?
  8. Improve the Model
    • If it’s not working perfectly—that’s normal. We can update the dataset to improve our model. 
    • Guide improvements:
      1. Add more training samples to each dataset
      2. Clean / Remove inconsistent data
      3. Retrain model

Tips for Running Activity

  • The micro:bit must be worn for this activity
  • The micro:bit doesn’t collect data on sound, so connecting it to AI only uses movement / accelerometer data
  • Expect:
    • Inconsistent models (this is GOOD for learning)
    • Need for clear, repeated training data
  • Emphasize:
    • AI depends on the data we give it
    • AI makes predictions, not perfect decisions
    • Humans are responsible for training and improving AI

Reflection / Exit Ticket Questions

  • How did your AI learn to recognize sounds?
  • What made your model more accurate?
  • What mistakes did it make?
  • How is this different from normal coding?

Extension Opportunities

Students can:

  • Add more sound categories (e.g., tap, voice commands)
  • Control external components (LEDs, servos)
  • Build a sound-controlled device
  • Compare AI vs non-AI sound detection

Elements of this resource were created by BBC micro:bit, then curated by the team at Nextech.

Learn More