Understanding the electronic connection
To ensure the robot operates correctly, all the components described in the previous section must be properly connected. The most complex part is connecting the Raspberry Pi pinout to the motor controller module, as shown in Figure 12.4. In Figure 12.4, you can see that the Raspberry Pi Model 3B includes several pins designated for similar purposes. First, both boards need to share a common ground. Connect the ground output of the L298N controller to pin 39 on the Raspberry Pi. Next, each motor requires three pin connections:
- Raspberry Pi PWM outputs -> ENA and ENB: These pins are used to enable motor actuation and regulate its velocity. The higher the PWM value, the faster the motor will rotate. In the diagram, we used pins 33 and 32 of the Pi.
- Raspberry Pi GPIO -> IN1 and IN2: These pins are used to regulate the rotation direction of the motor. We used pins 19 and 21 of the Raspberry Pi; setting the value of the GPIOs...