Model-Pi motor driver is a specially designed L298N board which provide all the functions of traditional L298N motor board. In addition, Model Pi board also provide a USB 5V output port which can provide power for Raspberry Pi.
You can buy this Model Pi board in : https://osoyoo.store/products/model-x-l298n-motor-driver-board-for-raspberry-pi
In this lesson, we will teach you how to use Model-Pi L298N motor and Raspberry Pi to control two DC motors. The DC motors can be installed in any robot cars to make car go forward, backward, left turn , right turn etc.
1)Connect Model-Pi board to Raspberry Pi and battery box (OSOYOO 18650 battery box or 9V square battery box)
2)Connect Model-Pi to two DC motors.
3)Connect Model Pi control ports to Raspberry Pi GPIO ports
Raspberry Pi to Model-Pi (or Model X) board
|Pin 16(GPIO 23)||IN1|
|Pin 18(GPIO 24)||IN2|
|Pin 13(GPIO 27)||IN3|
|Pin 15(GPIO 22)||IN4|
|Pin 12(GPIO 18)||ENA|
|Pin 33(GPIO 13)||ENB|
If you don’t know the GPIO PIN location in Raspberry Pi, check following pin map:
now turn on the battery box and make sure Raspberry Pi and Model Pi board both have LED turned on.
use putty(in windows) or ssh command(in linux or MacBook) to connect raspberry pi, then type following command:
Your two motors will make following movement
At beginning: both motors rotate forward
Then both motors rotate backward
then left motor rotates backward and right motor moves forward
finally left motor rotates forward and right motor moves backward
you can download the python code from http://osoyoo.com/driver/mecanum/modelpi.py
We have written detail comments in above python code to help you understand the working principal of motors.
DownLoad Url osoyoo.com