Tutorials
Tutorials
Tracking system
ZYA0017
V2.02.308.03
2 / 25
This tutorial includes the content of the file as shown in the figure below to help you learn more about this kit and
programming knowledge:
"1_Get_start": This folder stores the robot assembly guide and necessary software environment files, etc. In order to
complete the assembly accurately and quickly, please be sure to review it in detail and assemble it according to the manual.
At the same time, the premise of realizing the program function is to create the software environment correctly, please check
"2_Arduino_Code": This folder is used to store Arduino code files, and each code file is uploaded and used independently;
After completing the environment creation, follow this tutorial to complete program burning and realize interesting
1.1 Description
Before assembling this kit, you need to reset the servos, which will make it easier for you to assemble your light tracking
system accurately. After burning the code successfully, wait for the servo to reset. After the reset is completed, please do not
change the angle of the servo center shaft at will, which will affect the assembly. For more details, please see the attached
Open the first code file in the Arduino IDE software (path: 2_Arduino_Code\1_Reset\1_Reset.ino)
Connect the main control board to the computer with a USB cable and check that the Board Type and Serial Port settings
are correct. Here we choose the board type as UNO, and the serial port COM number as COM5. Note: The board type
here is Uno and the serial port is COM5 . Actually the serial port appears to be different for everyone, even though COM
4 / 25
Click the "upload" upload button to complete compiling and uploading the code.
After the upload is successful, you can hear the servos start to reset, keep the angle of the servos and start assembling your
2. Tracking system
2.1 Description:
After the assembly of the tracking system is completed, the burning of the tracking code and the effect test begin. Prepare a
flashlight or other equipment with a light source in advance to test the effect of the follow light system.
Open the code file of the light tracking system (path: 2_Arduino_Code\2_Sunflower\2_Sunflower.ino )
After burning the code, the light tracking system will also be reset, and it will start to detect the surrounding lighting
Use a flashlight to illuminate the photosensitive sensor from different directions to observe the movement of the
photovoltaic panel. If the rotation is found to be reversed, please check whether the wiring pins are consistent with those in
the assembly manual. (Note that the G\V\S in the sensor should be consistent with that in the expansion board)
7 / 25
So far, the effect of the light tracking system has been understood, and the following content mainly learns more detailed
3. Servo
3.1 Description:
In this section, you will learn about the knowledge of the steering gear (servo motor) and learn how to adjust the angle of
This servo motor can rotate about 0°~180°, the initial 0° position of the servo needs to be determined before assembly:
( Because the reset program is burned, the content of this section is only for understanding )
1. Install the steering gear crank on the steering gear, slowly turn the crank clockwise to the limit position, and remove the
crank
9 / 25
+ =
2. Reinstall the crank to be installed in the vertical direction to determine the initial 0° position, and turn the crank
0°
90°
180°
(1) (2) (3)
3. It is worth noting that the range of the horizontal steering gear used in this course is 5° to 175°, and the range of the
vertical steering gear is 20° to 100° (leave a limit position margin to avoid getting stuck)
10 / 25
4. After fixing the servo, turn the crank of the servo to the 90° position, and then assemble other parts.
A servo motor has three wires: power, ground, and signal. The power wire is usually red and connects to the "V" pin on the
UNO expansion board. The ground wire is generally black or brown and should be connected to the ground "G" pin of the
expansion board. The signal pin is usually yellow, orange or white and should be connected to the "S" pin on the expansion
board.
Schematic:
11 / 25
Wiring diagram:
12 / 25
Horizontal
vertical
13 / 25
4. Photoresistive sensor
4.1 Description
There are four photoresistive sensors used in this section, which correspond to the detection of light intensity in four
directions.
Take the average value of two adjacent photoresistive sensors and compare it with the average value of the other two
sensors. Under the control of the motor, the solar panel turns to the side with higher light intensity. For example:
14 / 25
As shown in the figure above, when the average light intensity received by the upper two sensors is greater than the average
light intensity of the two lower sensors, the solar panel will rotate and move in the upward direction, which is the direction
of the vertical servo motor in the right figure, and the opposite direction of light intensity is then The servo motor just
reverses until the motor turns to the set limit angle position.
15 / 25
As shown in the figure above, when the average light intensity received by the two sensors on the right is greater than the
average light intensity of the two sensors on the left, the solar panel will rotate and move in the right direction, that is, the
horizontal servo motor in the right figure turns in the direction of the arrow, and the opposite light intensity direction, then
the servo motor reverses the same way until the motor turns to the set limit angle position.
Notice:Each photoresistive sensor has three wiring pins, from left to right: data transmission pin, power supply pin, wiring
pin ("S", "V", "-"). When connecting, the "-" pin is connected to "G", the middle pin is connected to "V", and the "S" pin is
connected to "S".
16 / 25
5.1 Description
In the previous study, we have learned the principle of the light-following system. Under the light intensity at a certain angle,
the solar panel can face the light source. This lesson mainly learns how the solar panel converts solar energy into electrical
energy and transmits it under the light source. It is a three-digit digital tube.
Wiring diagram:
19 / 25
Renderings:
20 / 25
As mentioned earlier, set the initial angle and limit angle of the two servo motors
// Horizontal server Settings
Servo horizontal; // Horizontal server
int servoh = 90 ; // Default angle
21 / 25
Set part of the code to let the servo motor enter the initialization position, so you will see that the solar panel will quickly
// for(int i=servovLimitLow;i<servovLimitHigh;i+=2)
// { vertical. write(i);
// delay(30);
// }
// //vertical.write((servovLimitLow + servovLimitHigh)/2);
// delay(100);
// //Test horizontal
// for(int i=servohLimitLow;i<servohLimitHigh;i+=2)
// { horizontal. write(i);
// delay(30);
// }
// //horizontal.write((servohLimitHigh + servohLimitLow)/2);
//If there is no problem with the test, you can remove the code here.
}
The green part is the comment code, which is used to test the process when the angle minimum value servovLimitLow
rotates to the angle maximum value servovLimitHig, and can be deleted after the test is ok.
The principle of light tracking is mentioned in the previous content. Similarly, the following program sets the variables of
the intensity of light received by the four sensors, and controls the rotation of the steering gear by comparing the average
23 / 25
servov = servovLimitHigh;
}
}
else if (avt > avd)
{
servov= --servov;
if (servov < servovLimitLow)
{
servov = servovLimitLow;
}
}
vertical . write (servov); //If the rotation angle of the servo is opposite to the light, use (180- servov) or (servov) to change the direction.
}
//Check whether the difference is within the tolerance range, otherwise change the horizontal angle
if (- 1 *tol > dhoriz || dhoriz > tol)
{
if (avl < avr)
{
servoh = --servoh;
if (servoh <servohLimitLow)
{
servoh = servohLimitLow;
}
}
25 / 25