Welcome to Building:bit Superkit repository
6.Drive motor
Drive motor
Drive motor1. Learning objectives2. Motor wiring3. Programming3.1 Add expansion package3.2 Building blocks used3.3 Combining blocks4. Experimental phenomenon
1. Learning objectives
In this course, we mainly learn how to drive the motor connected to the superbit expansion board through MakeCode graphical programming.
The motor interface is located on the expansion board as shown in the figure below.
2. Motor wiring
Insert the motor wiring into the M1 interface of the Super:bit expansion board, and the black wiring is close to the battery side, as shown in the figure below.
3. Programming
Method 1 Online programming:
First, connect the micro:bit to the computer via a USB data cable, and the computer will pop up a U disk. Click the URL in the U disk: https://makecode.microbit.org/ to enter the programming interface. Then, add the Yahboom smart software package https://github.com/YahboomTechnology/SuperBitLibV2 to start programming.
Method 2 Offline Programming:
Open the offline programming software MakeCode and enter the programming interface. Click [New] and add the Yahboom smart software package https://github.com/YahboomTechnology/SuperBitLibV2 to start programming.
3.1 Add expansion package
3.2 Building blocks used
The location of the building blocks required for this programming is shown in the figure below.
3.3 Combining blocks
The summary program is shown in the figure below.
You can also directly open the microbit-MotorDriver.hex file provided in this experiment and drag it into the browser that opens the URL, and the program diagram of this project source code will be automatically opened
4. Experimental phenomenon
After the program is successfully downloaded, the micro:bit dot matrix will display a heart pattern, as shown in the figure below. Then we can see that the motor starts to rotate forward for 1 second, stops for 1 second, and reverses for 1 second, and keeps circulating in this state.
If you need to restart, please press the reset button on the back of the micro:bit motherboard.