Chapter17 :IR 리모트 컨트롤¶
1.Preparation¶
1.You should learn about the position of the infrared receiver in the body of hellobot;
2.You should learn about the principle of the infrared infrared receiver.
10-1-1 position of the infrared receiver in the body of hellobot
The infrared receiver is integrated on the left side of the expansion board. When you use the infrared remote controller, the remote controller needs to be aligned with the infrared receiver to receive the signal and perform corresponding actions.
10-1-2 schematic
10-1-3 Pins of Micro:bit
From the schematic diagram. You can see that infrared receiver is connected to P8 of Micro:bit. Therefore, in the program, it is necessary to initialize the infrared receiving pin, and then you can write the program to set the action corresponding to the key value of the infrared remote control.
Infrared remote control principle:
The infrared remote control emits modulated infrared light waves; the infrared receiver receives the infrared signals and converts them into corresponding electrical signals, which are then sent to the post amplifier. In this experiment, we used an infrared remote controller to control the movement of the car.
Note:The infrared obstacle avoidance sensor is not working properly due to the interference of outdoor light. This course needs to be carried out indoors and the curtains are covered to block the outdoor light.
10-1-4 Infrared remote control code value
// 00FF00FF red_colorful lights
// 00FF30CF blue_colorful lights
// 00FF708F purple_colorful lights
// 00FF40BF green_colorful lights
// 00FF10EF turn left in place
// 00FF50AF turn right in place
// 00FFB04F 0 sing
// 00FF08F7 1 green_arm colorful lights
// 00FF8877 2 red_arm colorful lights
// 00FF48B7 3 yellow_arm colorful lights
// 00FF28D7 4 Control the servo rotation of J2 interface
// 00FFA857 5 white_arm colorful lights
// 00FF6897 6 Control the servo rotation of J3 interface
// 00FF18E7 7 Control the servo rotation of J2 interface
// 00FF9867 8 blue_arm colorful lights
// 00FF58A7 9 Control the servo rotation of J3 interface
2.Learning goals
In this course, we will study how to control car by infrared controller.
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.
10-1-5 total program
The locations of blocks in the total program are shown in the following figure.
10-1-6
10-1-7
10-1-8
10-1-9
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 10-1-10 to download the program to micro:bit.
10-1-10
5.Phenomenon
After the code is uploaded. You can control HelloBot by infrared remote controller. When you press and “2” key, colorful lights and arm color lights are become red. When you press and “5” key, colorful lights are become blue and arm color lights are become green. As shown in the following figure. (Just for example)
10-1-11