Welcome to Building:bit Superkit repository
4.Micro:bit handle control
Micro:bit handle control
Micro:bit handle control1. Learning objectives2. Building blocks3. Motor wiring4. Programming4.1 Add expansion package4.2 Blocks used4.3 Add new variables4.4 Combined blocks5. Experimental phenomenon
1. Learning objectives
In this course, we mainly learn how to use MakeCode graphical programming to control the oscillating fan with the microbit handle.
2. Building blocks
For the building blocks steps, please refer to the installation drawings of [Assembly Course]--[Oscillating fan] in the materials or the building blocks installation brochure.
3. Motor wiring
The building blocks motor wiring is inserted into the M1 interface of the Super:bit expansion board, and the black wiring is inserted into the side close to the battery.
The building blocks servo wiring is inserted into the S1 interface of the Super:bit expansion board, and the orange servo wiring is inserted into the yellow pin of S1.
As shown below:
4. Programming
Method 1 Online Programming:
First, connect micro:bit to the computer via a USB data cable. A USB flash drive will pop up on the computer. Click the URL in the USB flash drive: https://makecode.microbit.org/ to enter the programming interface. Then, add the Yahboom software package to start programming.
Method 2 Offline Programming:
Open the offline programming software MakeCode and enter the programming interface. Click [New] and add the Yahboom software package to start programming.
superbit kit expansion package: https://github.com/YahboomTechnology/SuperBitLibV2 handle expansion package: https://github.com/YahboomTechnology/GHBitLib
4.1 Add expansion package
4.2 Blocks used
The location of the blocks required for this programming is shown in the figure below.
4.3 Add new variables
① Find the [Variable] option in the building block bar ---- [Set variable]
② Enter the variable name to complete the new variable.
4.4 Combined blocks
The microbit summary program on the Oscillating fan is shown in the figure below
The handle rocker control program is as follows
The handle gravity control program is as follows
You can also directly open the microbit-handle-control-Oscillating-fan.hex、microbit-Handle-rocker-control.hex、microbit-Handle-gravity-control.hex Drag the file into the browser that opens the URL, and the program diagram of the source code of this project will be automatically opened
5. Experimental phenomenon
We need to download the Oscillating fan program to the micro:bit mainboard of the Oscillating fan, turn on the power switch of the Oscillating fan, and we can see a heart pattern displayed on the micro:bit dot matrix;
Download the handle remote control program to the micro:bit mainboard of the handle, turn on the power switch of the handle, and 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 Oscillating fan.
The handle functions are as follows.

!Note: When the rocker is used for control, pressing the rocker will turn off the RGB light. This function does not exist when the handle is controlled by gravity.