SunFounder PiCar-S
Here, we need to set another variable – the steering angle – to distinguish between the large-angle and small-angle
turning. If the light is at the central left side (status [1,1,0]), we should apply a small-angle turning; if the light is at
the edge of the left side (status [1,0,0]), we should apply a large-angle turning.
Functions Explanation
To understand the code, take the software subflows above for reference.
Three Python modules are used in the code including the imported
light_follower_module
,
front_wheels
, and
back_wheel
previously. They are drivers for this kit, respectively for light following, front wheels and rear wheels.
The related classes have been defined here. When the modules are applied to use, objects will be created for related
classes, and different parts of hardware will be driven by calling a function by the class object.
For example, for the light following module, we create an object named
lf
:
lf = Light_Follower.Light_Follower()
Then we can call the function by a class object.
A0 = lf.read_analog()[0]
This function
read_analog()
will return a list with three elements, which stores the detected analog values of three
probes. Here we use
A0 = lf.read_analog()[0]
,
A1 = lf.read_analog()[1]
, and
A2 = lf.read_analog()[2]
to store three
elements of returned value separately into the variables A0-A2.
1.8. Arming the Car!
59
Summary of Contents for PiCar-S
Page 1: ...SunFounder PiCar S www sunfounder com Nov 10 2021 ...
Page 2: ......
Page 4: ...ii ...
Page 8: ...SunFounder PiCar S 4 Chapter 1 About the PiCar S ...
Page 9: ...SunFounder PiCar S 1 1 3 Mechanical Fasteners 1 1 Components List 5 ...
Page 10: ...SunFounder PiCar S 1 1 4 Wires 6 Chapter 1 About the PiCar S ...
Page 11: ...SunFounder PiCar S 1 1 5 PCB 1 1 Components List 7 ...
Page 12: ...SunFounder PiCar S 1 1 6 Other Components 8 Chapter 1 About the PiCar S ...
Page 22: ...SunFounder PiCar S 18 Chapter 1 About the PiCar S ...
Page 26: ...SunFounder PiCar S 22 Chapter 1 About the PiCar S ...
Page 27: ...SunFounder PiCar S 1 4 Circuits Building 1 4 1 Connect the Power 1 4 Circuits Building 23 ...
Page 28: ...SunFounder PiCar S 1 4 2 Connect the Modules 24 Chapter 1 About the PiCar S ...
Page 29: ...SunFounder PiCar S 1 4 3 Connect the Servo 1 4 Circuits Building 25 ...
Page 69: ...SunFounder PiCar S Subflow of Line Following Function 1 8 Arming the Car 65 ...
Page 74: ...SunFounder PiCar S 70 Chapter 1 About the PiCar S ...