Control robot with hand gestures bbc micro:Bit and teachable machine

Control Robot With Hand Gestures

Train AI to Control Micro:Bit Robot with Hand Gestures

Introduction

Controlling robots with hand gestures is an exciting intersection of artificial intelligence (AI) and hardware. In this tutorial, you will learn how to train an AI model to control a Micro:Bit robot using hand gestures, leveraging tools like Teachable Machine and Micro:Bit’s Bluetooth connectivity.

Requirements

  • A computer
  • BBC Micro:Bit board – you can use ANY Micro:Bit based robot
  • Internet connection

Setting Up Teachable Machine

To train an AI model, you will use an online tool called Teachable Machine. This app allows you to create machine learning models without coding. You can access it through your browser and follow these steps:

  1. Open Teachable Machine: Go to the Teachable Machine website.
  2. Create New Project: Choose an image project and create classes for each hand gesture, such as left, right, up, down, open, and close.
  3. Capture Gestures: Use your webcam or smartphone camera to capture images for each gesture.
  4. Train the Model: Click the “Train Model” button and let the app process your images.
  5. Export the Model: Once trained, export your model and save the sharable link.

Integrating with Micro:Bit

On the Micro:Bit side, the board receives class names via Bluetooth. Here’s how you can integrate the AI model with your robot:

  1. Open MakeCode: Go to the MakeCode editor and create a new project.
  2. Code the Movements: Use simple if conditions to map each class name to specific motor actions, such as turning left or right.
  3. Enable Bluetooth: Ensure that your project settings enable Bluetooth discoverability – set it to JUST WORKS

Code example for Fork Lift

Connecting the AI Model

To connect the AI model to the Micro:Bit:

  1. Open Teachable Micro:Bit App: Available on the Cardboard Robots website.
  2. Paste the Model Link: Enter the link you saved earlier – you can use my example model – https://teachablemachine.withgoogle.com/models/gvyJ_T8sh/
  3. Connect via Bluetooth: Click the robot icon and pair with your Micro:Bit.

Tips for Training AI Models

Training AI models for hand gestures can be challenging due to varying lighting conditions and angles. To improve accuracy:

  • Use consistent backgrounds.
  • Capture multiple images for each gesture.
  • Continuously test and refine your model.

Try it in oyur classroom!

This project demonstrates how machine learning AI and Micro:Bit can work together to create innovative solutions. With patience and experimentation, you can expand this concept to recognize facial expressions, objects, or any other inputs. Happy building!