Project 13: Move-in-Confined-Space Tank

(1)Description:

The ultrasonic sound-following and obstacle avoidance functions of the smart car have been introduced in previous projects. Here, we intend to combine the knowledge from the previous courses to confine the smart car to move within a certain space. In the experiment, we use the line-tracking sensor to detect whether there is a black line around the smart car, and then control the rotation of the two motors according to the detection results, so as to lock the smart car in a circle drawn with a black line.

The specific logic of the smart car is shown in the table below:

Condition

Movement

If one of three line tracking sensors detects black lines

Go back(set PWM to 150)Then turn left(set PWM to 150)

None of them detects black lines

Go forward(set PWM to 100)

(2)Flow chart

(3)Connection Diagram:

(4)Test Code:

You can also drag blocks to edit your code, as shown below

(1)

(2)

(3)

(4)

(5)

(6)

(7)

(8)

(9)

Complete Test Code

(Note: Do not connect the Bluetooth module before uploading the code, because uploading the code also uses serial communication, and there may be conflicts with the Bluetooth serial communication, which can cause the upload to fail.)

(5)Test Results:

After uploading the test code successfully and powering up, the smart car moves in a circle drawn with a black line.