cGO Competitive robotics based learning platform.© 2013 Jason Berry

cGO
Competitive robotics based learning platform.
© 2013 Jason Berry

WIT undergraduate flagship project.
jberry@wit.ie

Tuesday, 5 May 2026

Lesson Plan 1 - Stop/Go Vision System

Lesson Plan 1

Stop/Go Vision System

 

1: Lesson Overview

Students will learn how to make a basic vision system that will get the bot to start and stop moving depending on whats visible in the camera. In this lesson a device such as a phone will be acting as the camera.
 

2: Learning Objectives

After completing this lesson, students will be able to:
  1. Configure a Bluetooth Serial Bridge between Phone and Micro:Bit 
  2. Run a Vision Model from their phone.
  3. Program basic conditional logic (if/else statements).
  4. Connect their code to the vision model.
     

3:  Materials Required

  • Robotic Base
  • Laptop or Tablet for Programming and Teachable Machine 
  • Micro-USB Cable 
  • Phone for Vision System Camera
  • Distinct Visual Markers for Machine Model to pick up (Red Sign/Green Sign)


4:  Setup

Robotic Base Setup:

  •  Ensure the battery for the Robotic Base is charged.
  

Phone/Tablet Setup (Android):

  • Install a compatible Web Browser (Google Chrome, Microsoft Edge or Samsung Internet) 
  • Enable Bluetooth on the device 
  • Navigate to the Teachable Micro:Bit Web Application
  • Tap the Three Dots (⋮) and scroll down to "Add to home screen"
  • Tap "Install ↓" and "Install" on the pop-up.
  • A new application will be in your apps menu called "Teachable Micro:Bit"
 

Laptop / Micro:Bit Setup

  •  Navigate to the Micro:Bit Makecode Website
  •  (Optional) Sign-In to an account to save code on the cloud.
  •  Create (+) a new project with default options.

 ⚠️ Micro:Bit Bluetooth Troubleshooting

 If there are issues when connecting the Micro:Bit to the Teachable Micro:Bit application, the following steps can be taken:
  • In the MakeCode Project click the Settings Icon (⛭) and then click "Project Settings"
  •  Ensure "No Pairing Required" is enabled
  • Click "Edit Settings As text"
  • In the "Config" -> "Bluetooth" section add in the line "pairing_mode": 0,
 

 

 5: Lesson Activity

Part 1: Training the Model 

  1.   Navigate to the Teachable Machine website and click "Get Started" 
 
 
 2.     Click "Image Project" and "Standard image model" 
3.   Rename the default "Class 1" and "Class 2" to "go" and "stop" respectively by clicking on the pencil (✎) icon beside the text.
4.  Click the "Webcam" button. Your browser may ask for permission to access the camera. Ensure that this permission is granted. 
You should see your webcam activated in the left hand side of the screen once the permission is granted.

5.  Now the model can be trained. For the "go" class using the green "Go Sign" stand in various different places in the camera feed while using the "Hold to Record" button to take as much samples as needed. Try to get a variety of different distances and positions of the sign to make the model as reliable as possible.
 
Tip: By pressing the Gear (⚙) Icon on the webcam feed, the toggle for "Hold to Record" can be disabled and instead a Capture for X number of seconds setup can be used. This may make it easier for samples at further distances.  

 6.  For the "stop"class again stand in various different places in the camera feed with the "Stop Sign" visible, holding the "Hold to Record" button to take as much samples as needed.
 
7.  Once the number of samples is satisfied, click the "Train Model" button. It will begin to train the model. Keep the Teachable Machine website open and active while training the model.
 
8.  You will now be able to see the model in action. Try standing at various spots holding up the different signs and see how accurate your model is! If it requires further adjustments you can simply repeat Steps 4-7 adding more samples for areas that are weak.
 
9.   Once the model is complete you can click the "Export Model" button and then the "Upload my Model" button. 
 
Note: This does not upload any of the sample photos to Google Cloud, just the framework for the model. 
 
 
 
10.  Once the model is uploaded you will be provided with a Sharable Link. Make sure to copy this link to a safe space. fire
 
 

 

Part 2: Programming the Micro:Bit

1.  Navigate to the MakeCode Micro:Bit website and click "New Project" and name it appropriately.
 

 
2.  Once in the Project, Click "Extensions +" and search for Bluetooth
 
3. You will receive a prompt that "Some extensions will be removed". Click the "Remove extension(s) and add bluetooth" button
 
4.  Firstly in the code, the Bluetooth is enabled on the Micro:Bit:
bluetooth uart service Block is located in Bluetooth -> More (⋮)
 

 5.  Next, the data received from the Bluetooth connection is read and fed into a newly created variable "receivedString"
 
> To create the new variable click on Variables -> Make a Variable and type "receivedString" into the box.
> You will then have access to the set receivedString to Block.
> The bluetooth on data received Block is located in the Bluetooth menu.
> The bluetooth uart read until Block is located in Bluetooth -> More (⋮).
 
 
6.  Now the conditional logic has to be implemented. 
> From the Basic tab, get a forever block.
> From the Logic tab, get a if/then block. (Press the + on the block twice and then - once to get If/Else If)
> From the Logic tab, get two String Equals (=) comparison blocks.
> Get the received string "pill" from the Variables tab.
>  Click Advanced -> Pins and scroll down to Servo.
> Get four servo set pulse pin blocks and set all to 1500. 
Note: 1500 is the minimum number to make the bot go forward.
> Set two blocks to P1 and two blocks to P2.
 
 
 
This is the complete code.
 
7.  Now the code must be flashed to the Micro:Bit.
> Plug the Micro:Bit into a laptop using a Micro USB Cable.
> Once connected, the Download button on MakeCode website should have a Micro:Bit logo appear on it.
> Clicking Download should directly flash the code onto the board.
Note: If the Micro:Bit isn't automatically picked up, on clicking Download the webpage will try guide you in how to pair the Micro:Bit to MakeCode.
Note: To use this feature the browser must support WebUSB. Google Chrome is recommended.
> The Micro:Bit now successfully has the code flashed!
 

 
 

 Part 3: Connecting Micro:Bit to Stop/Go Model

 1. Open the Teachable Micro:Bit app on Android Device prepared earlier (see Phone/Tablet Setup). 
 


 
 
 
 2.  Enter the link copied from Teachable Machine earlier into the prompt and press OK. You will now see a camera feed and what class from your model it detects below. (Accept permission to access Camera if prompted.) 
 
3.  Tap the Robot Icon in the top right corner of the screen and power on the robot base. If the code is flashed correctly, the Micro:Bit should appear on the Bluetooth menu here. Tap BBC micro:bit and tap "Pair". 
 
 
4.  The Micro:Bit and Teachable Machine model are now connected. Holding up a particular sign in the phone camera feed should cause the robotic base to "go" and "stop" respectively.
 

Conclusion

If all was successful, the robotic base will be controlled using Stop and Go signs based on a machine learning model made by the students.  

No comments:

Post a Comment