Chapter10 :헬로봇 춤추고 팔 흔들기¶
1.Preparation¶
1.You should learn about the position of the motors in the body of hellobot;
2.You should learn about the principle of the motors.
3.You should learn how to drive the motors with the PCA9685PW.
(a)Left motor on the hellobot (b)Right motor on the hellobot
6-2-1 two motors
The HelloBot robot uses two yellow TT DC gear motors, and the rotation of the motor drives the wheel forward. The motor on the left is connected to the left side of the expansion board, and the motor on the right is connected to the right side of the expansion board.
6-2-2 servos on arm of hellobot
Tow servos is the robot's joint, which is mounted on the two arms of the HelloBot. You can control servos rotate degree to control arms.
6-2-3 buzzer on arm of hellobot
You need to look forward from the back of the robot, the left servo is connected to the J3 interface, and the right servo is connected to the J2 interface. The brown line of the servo corresponds to GND, the red line corresponds to VCC, and the yellow line corresponds to IO.
6-2-4 schematic of servo
6-2-5 schematic of motor drive
6-2-6 schematic of buzzer
6-2-7 schematic of PCA9685PW
6-2-8 Pins of Micro:bit
From the schematic diagram. You can see that tow motors is connected to LINA(12)、LINB(13)、RINA(14)、RINB(15) of PCA9685PW.
PCA9685PW is a 16-bit LED controller with IIC bus interface. Each LED can output 12-bit resolution (4096 levels) fixed-frequency independent PWM.
- Learning goals
In this course, we will learn how to make HelloBot robot advance, back, turn left, turn right, arm swing, sing, dance.
3.Programming
3.1 Programming online
1) You should use the USB cable to connect the micro:bit to the computer, at this point, the computer will have a micro:bit U disk. You need to open it, click micro:bit website, then entered the micro:bit website or you can enter the URL directly in your browser: http://microbit.org/
2) After entering the programming interface, you need to click Add package and copy the HelloBot package URL: https://github.com/lzty634158/HelloBot to the input field, click to confirm the add package. Then you can use the blocks of the HelloBot package.
3.2 Programming offline
- You can double-click to use it. As shown in the following figure.
2) After entering the programming interface, you need to click Add package and copy the HelloBot package URL: https://github.com/lzty634158/HelloBot to the input field, click to confirm the add package. Then you can use the blocks of the HelloBot package.
Note: The package only needs to be added once. If you have added packages in the previous lessons, this course does not need to be added repeatedly.
6-2-9 total program
The locations of blocks in the total program are shown in the following figure.
6-2-10
6-2-11
6-2-12
4.Download programming
You need to make sure that the micro:bit development board is connected to the computer. Then you should click on the download in the lower left corner as shown in P 6-2-13 to download the program to micro:bit.
6-2-13
5.Phenomenon
After the code is uploaded. HelloBot start to play music, and advance, back, turn left, turn right, arm swing.
6-2-14