How to wire DC Motors with L298N H-Bridge Motor Controller and Raspberry Pi
L298N Motor Controller
Raspberry Pi
DC Motors
USB Cord and optional USB battery
9-12 volt battery
3 double PWM wires with Anderson Powerpole Connectors/female pins on one side and Male pins on the other
1 Male to Female PWM wire
6 PWM wires with female pins on both sides
Connect a double PWM wire to the 9-12 volt battery (using either Anderson Powerpole connectors or female pins) with male pins on the other side for the positive and ground
Next, insert the positive male pin into the very left of the three block terminal and the ground male pin into the center of the three block terminal. Also insert the one male to female wire into this center block (This is the ground wire from the motor controller to the Raspberry Pi)
*Note: You should see a red light bright up if you did this correctly
Lastly, tighten the screws as seen on top of the terminal
The next step is the connect the wires from the DC motors to the motor controllers.
First, insert a double PWM wire with the male pins into one of the two block terminals. It doesn't matter which side the positive and negative wires go into as long as they are not inserted into the same block*. Do the same thing with the other side.
*Note: whichever side of the two block terminal the pins go into each only then matters when coding
Lastly, connect the DC motors to the other side of these wires via female pins and/or Anderson Powerpole connectors
In order to control two DC motors with the motor controller, you must remove the two jumpers covering the ENA and ENB pins. You don't have to if you only want to control one motor.
Next, insert six single PWM wires with female ends on these pins so that you have all six in a row*.
*Note: there should be two pins above the ENA and ENB pins without wires inserted in them
Lastly, insert these PWM wires into a GPIO pin on the Rasberry Pi. At the same time, connect the ground wire you inserted earlier to one of the ground pins on the Pi. Take note on which GPIO pins you use as they will matter when coding.
Insert the USB cable into the Raspberry Pi using the USB-C port.
Then plug the cable in a USB battery or straight to your laptob to power the Pi.
You should see a light bright up.
The finished setup should look something like this and it will allow for the control of two DC motors via Raspbery PI