November 2018
Beginner
472 pages
13h 5m
English
This code will count the number of cycles up and down on the signal pin for each wheel, and print them as we go to test the sensors. We will run our motors for about 1 second.
Let's start with the usual robot class import and time:
from robot import Robotimport time...
Next, we'll add an import for a GPIOZero input device. We can use the pin it sets up to count our pulses:
...from gpiozero import DigitalInputDevice...
The encoders generate pulses; we will want to count them and track their state. We will use more than ...