yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
Building:bit Superkit📖
0.First Trial Video
1.Assembly Course
  • 1.1Mobile shooter
  • 1.2Pretty car
  • 1.3Clip robot
  • 1.4Proficient carrier
  • 1.5Skip car
  • 1.6Freestyle
  • 1.7Spider
  • 1.8Lifting platform
  • 1.9Biped robot
  • 1.10Changing Face
  • 1.11Carousel
  • 1.12Oscillating fan
  • 1.13Airplane
  • 1.14Unicycle
  • 1.15Auto-door
  • 1.16Dragon knight
  • 1.17Ultrasonic handheld rangefinder
  • 1.18Small flying car obstacle avoidance
  • 1.19Changing face
  • 1.20Adjustable RGB light
  • 1.21Adjustable fan
  • 1.22Photosensitive emergency light
  • 1.23Smart alarm clock
  • 1.24Light-controlled bipedal robot
  • 1.25Swimming robot avoid objects
  • 1.26Fleeing spider
  • 1.27Temperature humidity reminder
  • 1.28Temperature-controlled fan
  • 1.29Color recognition machine
  • 1.30Color-recognizing automatic door
  • 1.31Rokcer color changing light
  • 1.32Rokcer transporter
2.Preparation before class
  • 2.1 About BBC microbit
  • 2.2 Super:bit expansion board
  • 2.3 MakeCode Graphical Programming Guide
  • 2.4 MakeCode graphical API
  • 2.5 Python Programming Guide
  • 2.6 Superbit MicroPython API
  • 2.7 Notes on charging and battery use
3.Basic modeling MakeCode course
0.Basic course
  • 1.Buzzer play music
  • 2.Control RGB color
  • 3.Control all RGB lights
  • 4.Drive 270°building block servo
  • 5.Drive 180° servo
  • 6.Drive motor
A.Mobile shooter
  • 1.Cannonball shooting
  • 2.Music fortress
  • 3.APP control
  • 4.Micro:bit handle control
  • 5.WiFi camera control
B.Pretty car
  • 1.Dancer
  • 2.APP control
  • 3.Micro:bit handle control
  • 4.WiFi camera control
C.Clip robot
  • 1.Dancing and singing
  • 2.Button control clip
  • 3.APP control
  • 4.Micro:bit handle control
  • 5.WiFi camera control
D.Proficient carrier
  • 1.Dancing
  • 2.Button control shovel
  • 3.Transportation
  • 4.APP control
  • 5.Micro:bit handle control
  • 6.WiFi camera control
E.Skip car
  • 1.Dance battle
  • 2.Button control skip car
  • 3.Powerful carrier
  • 4.APP control
  • 5.Micro:bit handle control
  • 6.WiFi camera control
F.Freestyle
  • 1.Dancing and singing
  • 2.Freestyle advance
  • 3.APP control
  • 4.Micro:bit handle control
G.Spider
  • 1.Spider advance
  • 2.The dancing spider
  • 3.APP control
  • 4.Micro:bit handle control
  • 5.WiFi camera control
H.Lifting platform
  • 1.Automatic Lift
  • 2.Button control platform
  • 3.APP control
  • 4.Micro:bit handle control
I.Biped robot
  • 1.Walking
  • 2.Dancing and singing
  • 3.APP control
  • 4.Micro:bit handle control
J.Changing Face
  • 1.Changing face
  • 2.Bite the hand crocodile
  • 3.APP control
  • 4.Micro:bit handle control
K.Carousel
  • 1.Music carousel
  • 2.APP control
  • 3.Micro:bit handle control
L.Oscillating fan
  • 1.Colorful windmill
  • 2.Summer cooling artifact
  • 3.APP control
  • 4.Micro:bit handle control
M.Airplane
  • 1.Sailing Prelude
  • 2.APP control
  • 3.Micro:bit handle control
N.Unicycle
  • 1.Clumsy reptile
  • 2.APP control
  • 3.Micro:bit handle control
O.Auto-door
  • 1.Soldiers on duty
  • 2.Music door
  • 3.APP control
  • 4.Micro:bit handle control
P.Dragon knight
  • 1.Waving wings
  • 2.APP control
  • 3.Microbit handle control
4.Basic modeling Python course
0.Basic course
  • 1.Buzzer play music
  • 2.Control RGB color
  • 3.Control all RGB lights
  • 4.Drive 270° building block servo
  • 5.Drive 180° servo
  • 6.Drive motor
  • 7.Drive stepper motor
A.Mobile shooter
  • 1.Cannonball shooting
  • 2.Music fortress
  • 3.Micro:bit handle control
B.Pretty car
  • 1.Dancer
  • 2.Micro:bit handle control
C.Clip robot
  • 1.Dancing and singing
  • 2.Button control clip
  • 3.Micro:bit handle control
D.Proficient carrier
  • 1.Dancing
  • 2.Button control shovel
  • 3.Transportation
  • 4.Micro:bit handle control
E.Skip car
  • 1.Dance battle
  • 2.Button control skip car
  • 3.Powerful carrier
  • 4.Microbit handle control
F.Freestyle
  • 1.Dancing and singing
  • 2.Freestyle advance
  • 3.Micro:bit handle control
G.Spider
  • 1.Spider advance
  • 2.The dancing spider
  • 3.Micro:bit handle control
H.Lifting platform
  • 1.Automatic Lift
  • 2.Button control platform
  • 3.Micro:bit handle control
I.Biped robot
  • 1.Walking
  • 2.Dancing and singing
  • 3.Micro:bit handle control
J.Changing Face
  • 1.Changing face
  • 2.Bite the hand crocodile
  • 3.Micro:bit handle control
K.Carousel
  • 1.Music carousel
  • 2.Micro:bit handle control
L.Oscillating fan
  • 1.Colorful windmill
  • 2.Summer cooling artifact
  • 3.Micro:bit handle control
M.Airplane
  • 1.Sailing Prelude
  • 2.Micro:bit handle control
N.Unicycle
  • 1.Clumsy reptile
  • 2.Micro:bit handle control
O.Auto-door
  • 1.Soldiers on duty
  • 2.Music door
  • 3.Microbit handle control
P.Dragon knight
  • 1.Waving wings
  • 2.Micro:bit handle control
5.Sensor Advanced MakeCode coursenew
3.Sensor expansion course
  • 3.1 Avoiding car
  • 3.2 Changing Face
  • 3.3 Adjustable fan
  • 3.4 Photosensitive robot
  • 3.5 Swimming robot
  • 3.6 Spiders sense human body
  • 3.7 Temperature control fan
  • 3.8 Automatic safety door
  • 3.9 Rocker carrier car
2.Sensor basic course
  • 2.1 Hand-held range finder
  • 2.2 Adjustable RGB light
  • 2.3 Emergency light
  • 2.4 Vibrating alarm clock
  • 2.5 Infrared detection broadcast
  • 2.6Human body infrared detection broadcast
  • 2.7 Temperature and humidity broadcaster
  • 2.8 Color recognition machine
  • 2.9 Rocker control light
1.Sensor principle
  • 1.1 About ultrasonic sensors
  • 1.2 Ultrasonic ranging
  • 1.3 About potentiometers
  • 1.4 Adjust potentiometer
  • 1.5 About photosensitive sensors
  • 1.6 Read the light intensity
  • 1.7 About infrared modules
  • 1.8 Obstacle detection
  • 1.9 Introduction of module
  • 1.10 Human body detection
  • 1.11 About temperature-humidity modules
  • 1.12 Read temperature humidity
  • 1.13 About color recognition sensors
  • 1.14 Color recognition
  • 1.15 About rocker module
  • 1.16 Control rocker
6.Sensor Advanced Python coursenew
1.Sensor principle
  • 1.1 About ultrasonic sensorsnew
  • 1.2 Ultrasonic rangingnew
  • 1.3 About potentiometersnew
  • 1.4 Adjust potentiometernew
  • 1.5 About photosensitive sensorsnew
  • 1.6 Read the light intensitynew
  • 1.7 About infrared modulesnew
  • 1.8 Obstacle detectionnew
  • 1.9 About human infrared sensing modulesnew
  • 1.10 Human body detectionnew
  • 1.11 About temperature-humidity modulesnew
  • 1.12 Read temperature humiditynew
  • 1.13 About color recognition sensorsnew
  • 1.14 Color recognitionnew
  • 1.15 About rocker modulenew
  • 1.16 Control rockernew
2.Sensor basic course
  • 2.1 Hand-held range findernew
  • 2.2 Adjustable RGB lightnew
  • 2.3 Emergency lightnew
  • 2.4 Vibrating alarm clocknew
  • 2.5 Infrared detection broadcastnew
  • 2.6 Human body infrared detection broadcastnew
  • 2.7 Temperature and humidity broadcasternew
  • 2.8 Color recognition machinenew
  • 2.9 Rocker control lightnew
3.Sensor expansion course
  • 3.1 Avoiding carnew
  • 3.2 Changing Facenew
  • 3.3 Adjustable fannew
  • 3.4 Photosensitive robotnew
  • 3.5 Swimming robotnew
  • 3.6 Spiders sense human bodynew
  • 3.7 Temperature control fannew
  • 3.8 Automatic safety doornew
  • 3.9 Rocker carriernew
Download
  • APP(iOS_Android)
  • Code_PythonLibrary
  • Hardware manual
  • Bluetooth communication protocol
  • Assembly Instructions Manual
  • Makecode offline software
Download ZIP

Welcome to Building:bit Superkit repository

3.Micro:bit handle control

Microbit handle control

Microbit handle control1. Learning objectives2. Building blocks3. Motor wiring4. Code analysis4.1 Water Monster4.2 Handle5. Write and download the program6. Experimental phenomenon

1. Learning objectives

In this course, we mainly learn how to use Python programming to realize the microbit handle to control the water monster.

2. Building blocks

For the building blocks steps, please refer to the installation drawings of [Assembly course]-[Freestyle] in the materials or the building block installation album.

3. Motor wiring

The motor wiring on the left side of the car is inserted into the M1 interface of the Super:bit expansion board, and the black line is close to the battery side;

The motor wiring on the right side of the car is inserted into the M3 interface of the Super:bit expansion board, and the black line is close to the battery side;

As shown below:

image-20250611160433482

4. Code analysis

4.1 Water Monster

For the program, please refer to the Freestyle code.py file.

from microbit import *
import superbit
import radio
import neopixel
import microbit

First, import the libraries needed for this lesson from microbit: the superbit library is dedicated to the superbit expansion board; neopixel is used to control the RGB light; radio is used for the wireless communication function of micro:bit.

​x
np = neopixel.NeoPixel(pin12, 4)
​
display.show(Image.HEART)
microbit.sleep(1000)
radio.on()
radio.config(group=1)
mode = 1

np = neopixel.NeoPixel(pin12, 4): Initialize the RGB light settings. There are 4 RGB lights in total, connected to the P12 pin of the microbit motherboard (you can check the hardware interface manual for details);

display.show(Image.HEART): Display a heart pattern on the microbit dot matrix;

microbit.sleep(1000): Delay for 1 second;

radio.on(): Turn on the wireless function. Because the wireless function consumes more power and occupies more memory, it is turned off by default. You can also use radio.off() to turn off the wireless function;

radio.config(group=1): Configure wireless group=1, so that other microbit devices with wireless group=1 can communicate with each other. The default is 0, and the selectable group is 0~255. The set group value needs to be consistent with the handle setting, otherwise normal communication will not be possible;

mode = 1: Initialize the variable mode to 1.

xxxxxxxxxx
while True:
display.show(mode)
incoming = radio.receive()
if incoming == 'up':
superbit.motor_control(superbit.M1, -255, 0)
superbit.motor_control(superbit.M3, -255, 0)
...

In the main loop, determine the command sent by the handle to control the movement state of the water monster and the color of the RGB light.

incoming = radio.receive(): Receive the data transmitted wirelessly and save it to the incoming variable; if incoming is 'up', the motor will rotate, and if it is 'stop' and mode = 1, the motor will stop rotating;

If incoming is 'R', the body RGB will light up red, 'G' will light up green, 'B' will light up blue, and 'Y' will light up yellow.

xxxxxxxxxx
if incoming == 'turn_off':
np.clear()
np.show()
if mode == 1:
mode = 2
else:
mode = 1

Switch the current mode.

! Note:

The value of incoming needs to correspond to the value sent by the handle. Only the same value can receive and execute the command.

4.2 Handle

For the program, please refer to the Handle code.py file.

xxxxxxxxxx
from microbit import display, Image
import ghandle
import radio

First, import the libraries needed in this lesson from microbit: the ghandle library is dedicated to the micro:bit hand; radio is used for the wireless communication function of micro:bit.

xxxxxxxxxx
display.show(Image.HEART)
radio.on()
radio.config(group=1)

display.show(Image.HEART): Display a heart pattern on the microbit dot matrix;

radio.on(): Turn on the wireless function. Because the wireless function consumes more power and occupies more memory, it is turned off by default. You can also use radio.off() to turn off the wireless function;

radio.config(group=1): Configure wireless group=1, so that other microbit devices with wireless group=1 can communicate with each other. The default is 0, and the selectable group is 0~255. The set group value needs to be consistent with the handle setting, otherwise it will not communicate normally;

xxxxxxxxxx
while True:
​
if ghandle.rocker(ghandle.up):
radio.send('up')
display.show(Image.ARROW_N)
elif ghandle.rocker(ghandle.down):
radio.send('down') 
display.show(Image.ARROW_S) 
elif ghandle.rocker(ghandle.left): 
radio.send('left') 
display.show(Image.ARROW_W) 
elif ghandle.rocker(ghandle.right): 
radio.send('right') 
display.show(Image.ARROW_E) 
elif ghandle.rocker(ghandle.pressed): 
radio.send('turn_off') 
display.show(Image.NO) 
else: 
radio.send('stop') display.clear()

If ghandle.rocker(ghandle.up) is True, it means that the joystick of the handle is pushed up, so that the wireless sends the 'up' command and displays an upward icon;

If ghandle.rocker(ghandle.down) is True, it means that the joystick of the handle is pushed down, so that the wireless sends the 'down' command and displays a downward icon;

If ghandle.rocker(ghandle.left) is True, it means that the joystick of the handle is pushed to the left, so that the wireless sends the 'left' command and displays a left icon;

If ghandle.rocker(ghandle.right) is True, it means that the joystick of the handle is pushed to the right, so that the wireless sends the 'right' command and displays a right icon;

If ghandle.rocker(ghandle. pressed) is True, it means that the joystick of the handle is pressed, so the wireless sends the 'pressed' command and displays the 'X' icon;

If the remote control has no operation, send 'stop' and clear the display;

Special processing:

xxxxxxxxxx
if ghandle.rocker(ghandle.pressed):
if rocker_key == 0:
rocker_key = 1
radio.send('turn_off')
display.show(Image.NO)
else:
rocker_key = 0

When the joystick is pressed, we use a variable rocker_key to ensure that only one turn_off command is sent. Corresponding to the program of the water monster, change the value of mode once.

xxxxxxxxxx
if ghandle.B1_is_pressed():
radio.send('R')
display.show("R")
if ghandle.B2_is_pressed():
radio.send('G')
display.show("G")
if ghandle.B3_is_pressed():
radio.send('B')
display.show("B")
if ghandle.B4_is_pressed():
radio.send('Y')
display.show("Y")

Next, detect the buttons and send R', 'G', 'B', 'Y' commands to B1 (red), B2 (green), B3 (blue), and B4 (yellow).

5. Write and download the program

  1. Open the Mu software and enter the code in the editing window. Note! All English and symbols should be entered in English, use the Tab key for indentation, and the last line ends with a blank program.
  2. Click the thumb 'Check' button to check if there are any errors in our code. If a cursor or underline appears in a line, it means a syntax error. Please check and modify it. If there is no error, the lower left corner will prompt that there is no problem with the detection.

image-20250616213555929

  1. Click the 'REPL' button to check whether the Superbit library has been downloaded. If not, please refer to [Preparation before class] --> [2.4 Python Programming Guide].

image-20250616213637497

  1. After the program is written, connect the computer and microbit mainboard with a microUSB data cable, please click the 'Flash' button to download the program to the micro:bit mainboard. (You need to click the 'REPL' button again to turn off the import library file function before you can download the program normally).

image-20250616213730022

  1. If the download fails, please confirm whether the microbit is connected to the computer normally via the microUSB data cable and the Superbit Python library has been imported.

6. Experimental phenomenon

We need to download the Freestyle code.py file to the micro:bit motherboard of the water monster, turn on the power switch of the water monster, and we can see a smiley face pattern displayed on the micro:bit dot matrix;

Download the Handle code.py file to the micro:bit motherboard of the handle, turn on the power switch of the handle, we can see that the micro:bit dot matrix will be initialized to display a heart pattern, and then an "X" pattern will be displayed, indicating that the handle is in the default state and no data is sent.

The two will automatically complete the pairing, and then we can start to remotely control the water monster.

The handle function is as follows.

image.png

Handle joystick control:

After the handle and the water monster are successfully paired, we can see that the number 1 is displayed on the micro:bit dot matrix of the water monster, indicating that it is in mode 1 at this time.

In mode 1:

  • Push the joystick forward to control the movement of the paddle monster, and it stops when you release your hand;
  • Press the red button to light up the red RGB light;
  • Press the green button to light up the green RGB light;
  • Press the yellow button to light up the yellow RGB light;
  • Press the blue button to light up the blue RGB light.

We can press the joystick to switch to mode 2. At this time, we can see the number 2 displayed on the micro:bit dot matrix of the paddle monster, indicating that it is in mode 2.

In mode 2:

  • Push the joystick forward to control the movement of the paddle monster, and it will keep turning when you release your hand;
  • Press the red button to light up the red RGB light and stop the moving paddle monster;
  • Press the green button to light up the green RGB light;
  • Press the yellow button to light up the yellow RGB light;
  • Press the blue button to light up the blue RGB light.

Each time you press the joystick, it will switch back and forth between mode 1 and mode 2, and the RGB light will go out.

Handle gravity control:

After the handle and the water monster are paired successfully, we can see the number 1 displayed on the micro:bit dot matrix of the water monster.

  • The handle tilts forward to control the movement of the water monster, and it stops moving when it is placed horizontally;
  • Press the red button to light up the red RGB light;
  • Press the green button to light up the green RGB light;
  • Press the yellow button to light up the yellow RGB light;
  • Press the blue button to light up the blue RGB light.

(Note: There is only one mode for handle gravity control, and mode 2 cannot be switched)

Freestyle advance
Spider advance

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文