Created
December 13, 2020 22:55
-
-
Save duckida/cc4f4c88cc0feb20744e8338472effca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as gpio | |
import time | |
gpio.setmode(gpio.BCM) | |
gpio.setwarnings(False) | |
# Pins | |
ain1 = 16 | |
ain2 = 20 | |
pwma = 21 | |
bin1 = 26 | |
bin2 = 19 | |
pwmb = 13 | |
stby = 12 | |
## Setup | |
# Standby channel | |
gpio.setup(stby, gpio.OUT) | |
# PWM channels | |
gpio.setup(pwma, gpio.OUT) | |
gpio.setup(pwmb, gpio.OUT) | |
# Direction channels | |
gpio.setup(ain1, gpio.OUT) | |
gpio.setup(ain2, gpio.OUT) | |
gpio.setup(bin1, gpio.OUT) | |
gpio.setup(bin2, gpio.OUT) | |
## Control | |
while True: | |
# Standby | |
gpio.output(stby, gpio.HIGH) | |
# PWM channels | |
gpio.output(pwma, gpio.HIGH) | |
gpio.output(pwmb, gpio.HIGH) | |
# Direction channels | |
gpio.output(ain1, gpio.HIGH) | |
gpio.output(ain2, gpio.LOW) | |
gpio.output(bin1, gpio.HIGH) | |
gpio.output(bin2, gpio.LOW) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment