The <version> folder will be something like “0.75”. Use the latest version available.
cd ~/pibot
wget http://osoyoo.com/driver/picar/picar-line-tracking.py
python3 picar-line-tracking.py
exit
If you don't remember what a variable is, review the description from Lesson 1
The “If” statement allows the code to make decisions based on the result of a test. If the result is “True” or “1” then it executes assigns the first value, else the result was “False” or “0” and it assigns the last value.
The sts# variables are assigned a '0' value if the GPIO pin is a '1' and a '1' value if the GPIO pin is not a '1'.
See the Electrical Description section on the previous page for a description of how the sensors work
The second group of “If” statements are standalone and not part of assigning a value to a variable. This is the most common use of the “If” statement. When the expression after the “If” is “True” then it will run the code after the “If” statement, otherwise it will skip that code and go to the next statement
You can check for multiple values of a variable in an “If” statement by combining them with the “or” operator. When any of the values matches, then the result is “True”
The “or” operator is part of boolean logic which allows computers to make decisions based on any input. Boolean logic is the basis for how computers work.
Comments can be added to the code to describe what it is doing. They always start with a ”#“ character and everything else on the line after that is a comment and not run as part of the code. The comments in the code aren't always correct. Can you spot the errors?
The “While” statement is similar to the “If” statement. It will continue to run the code under it as long as the expression is “True”. We call this a loop because when it gets to the end of the code under the “While” statement it loops back to the beginning. How long do you think this “While” loop will keep running?
python3 picar-line-tracking.py
sudo shutdown -h now