import RPi.GPIO as gpio import time gpio.setmode(gpio.BOARD) gpio.setup(7, gpio.OUT) gpio.setup(11, gpio.OUT) gpio.setup(13, gpio.OUT) gpio.setup(15, gpio.OUT) gpio.output(7, True) gpio.output(11, True) gpio.output(13, True) gpio.output(15, False) time.sleep(0.5) gpio.cleanup()
Check out the video for connecting the motors to the L298n H-Bridge.
Here's some simple code that will run one of the motors for 0.5 seconds. Notice the use of gpio.BOARD for the gpio naming conventions.
Save this script as robot1.py, then, when everything is hooked up and you're ready to roll (get it!?!?!?), do sudo python robot1.py
Try swapping around the True and False statements in the outputs, see what changes it makes.
Now that we've got one motor working, let's work on adding the other three, and figuring out how to get them to work together!