November 2018
Beginner
472 pages
13h 5m
English
Open up robot.py from the last chapter. In the imports section, we will want the LineSensor object from GPIO Zero:
from gpiozero import LineSensor
In the constructor, the __init__ method for the robot object, we can set up our line sensors. While the names lsensor and rsensor are fine for the test code, in the robot object, we will have other sensors later, also on the left and right. So it's better to be explicit in naming these. We'll call them left_line_sensor and right_line_sensor. The following is that section of the code, with the new code in bold:
def __init__(self, motorhat_addr=0x6f): # Setup the motorhat with the passed in address self._mh = Raspi_MotorHAT(addr=motorhat_addr) # get local variable ...
Read now
Unlock full access