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 Building 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 realize the control of Biped robot by micro:bit handle.
2. Building blocks
For the building blocks steps, please refer to the installation drawings of [Assembly Course]--[Biped robot] in the materials or the building blocks installation book.
3. Motor wiring
Insert the motor wiring on the left side of the car into the M1 interface of the Super:bit expansion board, with the black wire close to the battery side;
As shown below:
4. Programming
Method 1 Online programming:
First, connect micro:bit to the computer via a USB data cable, and a U disk will pop up on the computer. Click the URL in the U disk: 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 Building blocks used
The location of the building 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 Biped robot 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 program provided in this experiment microbit-handle-control-Biped-robot.hex、microbit-Handle-rocker-control.hex、microbit-Handle-gravity-control.hex Drag the file into the browser with the URL opened, and the program diagram of the source code of this project will be automatically opened
5. Experimental phenomenon
We need to download the program of Biped robot to the micro:bit mainboard of Biped robot, turn on the power switch of Biped robot, and we can see that a heart pattern will be initialized on the micro:bit dot matrix.
Download the remote control program of the handle to the micro:bit mainboard of the handle, turn on the power switch of the handle, and we can see that a heart pattern will be initialized on the micro:bit dot matrix, 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 Biped robot.
The functions of the handle are as follows.
Handle rocker control:
After the joystick is successfully paired with the Biped robot, we can see the number 1 displayed on the micro:bit dot matrix of the Biped robot, indicating that it is in mode 1.
In mode 1:
- Push the joystick forward to control the Biped robot to move forward, and it will stop when you release your hand;
- Push the joystick backward to control the Biped robot to move backward, and it will stop when you release your hand;
- Press the red button to turn on the red RGB light;
- Press the green button to turn on the green RGB light;
- Press the yellow button to turn on the yellow RGB light;
- Press the blue button to turn on the blue RGB light.
We can press the joystick to switch to mode 2, and we can see the number 2 displayed on the micro:bit dot matrix of the Biped robot, indicating that it is in mode 2.
In mode 2:
- Push the joystick forward to control the Biped robot to move forward, and it will keep moving forward when you release your hand;
- Push the joystick backward to control the Biped robot to move backward, and it will keep moving backward when you release your hand;
- Press the red button to light up the red RGB light and stop the moving Biped robot;
- 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 Biped robot are successfully paired, we can see the number 1 displayed on the micro:bit dot matrix of the Biped robot.
- Tilt the handle forward to control the Biped robot to move forward, and stop when placed horizontally;
- Tilt the handle backward to control the Biped robot to move forward, and stop when 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 you cannot switch to mode 2)