### Project 10: Light-following Tank
#### **(1)Description:**
In previous projects, we introduced in detail the use of various sensors, modules, and expansion boards on the smart car. Now let’s move to the projects of the smart car . The light-following smart cars, as the name suggests, is a smart car that can follow the light.
We can combine the knowledge from projects photoresistor and motor drive to make a light-seeking smart car. In the project, we use two photoresistor modules to detect the light intensity on the left and right sides of the smart car, read the corresponding analog values, and then control the rotation of the two motors based on these two data so as,to control the movements of the smart car.
The specific logic of the light-following smart car is shown as below.

#### **(2)Flow chart:**

#### **(3)Connection Diagram:**

Note: The pin "G", "V" and S of the left photoresistor module are connected to G (GND), V (VCC), A1 respectively;
The pin "G", "V" and S of the right photoresistor module are connected to the G (GND), V (VCC), and A2 respectively.
The 4pin cable is marked with A, A1, B1 and B. The right rear motor is connected to B port of the 8833 motor driver expansion board and the left front motor is connected to A port of the 8833 motor driver expansion board.
#### **(4)Test Code:**
You can also drag blocks to edit your code, as shown below.
(1)
(2)
(3)
(4)
(5)
(6)
(7) 
**Complete Test Code**
(Note: The threshold 650 in the code can be adjusted appropriately according to the specific light intensity.
Do not connect the Bluetooth module before uploading the code, because the uploading of the code also uses serial communication, and there may be conflicts with the serial communication of the Bluetooth, which can cause the uploading of the code to fail.)

#### **(5)Test Results:**
After uploading the test code successfully, wire up, turn DIP switch to the ON end and power on, the smart car follows the light to move.
