Yahboom Omibox Robot Kit arduino IDE course 5.13 Infrared follow
1-1.The position of the Infrared sensor on the robot car
1-2.Learn about the Arduino Uno pins connected to the Infrared sensor of Omibox programmable robot
1-3.Learn to understand the principle of Tracking
The basic principle of the infrared sensor is to use the reflective nature of the object. When there is no obstacle in the front side, the infrared light emitted by the infrared sensor launching tube will gradually weaken due to the farther distance of the propagation, and finally disappear.
When there is an obstacle on the front side, the infrared light will be reflected to the receiving tube of the sensor.
We write the corresponding code according to this point to complete the robot infrared follow function.
According to the hardware manual, we can know that
Controlling the left motor forward is the Pin1 of the PCA9685.
Controlling the left motor back is the Pin2 of the PCA9685.
Controlling the right motor forward is the Pin15 of the PCA9685.
Controlling the right motor back is the Pin14 of the PCA9685.
The left infrared sensor is connected the A0 pin of the Arduino.
The right infrared sensor is connected the A1 pin of the Arduino.
3. About code
The main program of this experiment is as follows:
1.We need to open the code of this experiment: Infrared follow.ino, click“√” under the menu bar to compile the code, and wait for the word "Done compiling " in the lower right corner, as shown in the figure below.
2. Click 【Tools】 --- 【Board】 -- we need to choose Arduino Uno. As shown in the figure below.
3.In the menu bar of Arduino IDE, we need to select 【Tools】---【Port】--- selecting the port that the serial number displayed by the device manager, as shown in the figure below.
4. After the selection is completed, you need to click “ → ”under the menu bar to upload the code to the Arduino UNO board. When the word “Done uploading” appears in the lower left corner, the code has been successfully uploaded to the Arduino UNO board, as shown in the figure below.
After the program is uploaded, open the power of the robot car. The Omibox robot is stop, when the infrared sensor detects an obstacle, the robot advances along with the obstacle. When the obstacles are detected on both the left and right sides, the car advance, and when the obstacle is detected on the left side, the car turn left, and when the obstacle is detected on the right side, the car turn right.
!!!Note: In order to avoid the interference of sunlight on the infrared sensor, we must carry out the experiment indoors.
The code of the experiment: 13.Infrared follow.rar