Starting at line 1, we import PiGPIO and the Motor class defined in the motor_class.py file, before defining several variables describing how we are connecting the L293D to our Raspberry Pi's GPIO pins:
import pigpio # (1)
from time import sleep
from motor_class import Motor
# Motor A
CHANNEL_1_ENABLE_GPIO = 18 # (2)
INPUT_1Y_GPIO = 23
INPUT_2Y_GPIO = 24
# Motor B
CHANNEL_2_ENABLE_GPIO = 16 # (3)
INPUT_3Y_GPIO = 20
INPUT_4Y_GPIO = 21
Referring back to Figure 10.3 and Figure 10.4, if we consider the Motor A (channel 1) side of the circuits, we see that the logic pins are connected to GPIOs 23 and 24 at line 2 – INPUT_1Y_GPIO = 23 and INPUT_2Y_GPIO = 24. These logic pins (together with the enable pin that we will cover shortly) are used to set the state and rotational direction of the motor. The truth table for these states is shown as follows.
This table was sourced from the L293D datasheet and reformatted and supplemented to match...