Created
September 6, 2016 01:26
-
-
Save rxseger/91148576deeb619cbd2ec5b428b24b13 to your computer and use it in GitHub Desktop.
control 2-input H-Bridge with control and disable bit (K1=K4=C, K2=K3=not (C or D))
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
#!/usr/bin/python | |
import RPi.GPIO as GPIO | |
import sys | |
GPIO.setmode(GPIO.BOARD) | |
C = 38 # G20 | |
D = 40 # G21 | |
if len(sys.argv) < 2: | |
print "usage: %s [forward|reverse|coast]" % (sys.argv[0],) | |
raise SystemExit | |
GPIO.setwarnings(False) | |
GPIO.setup([C, D], GPIO.OUT, initial=GPIO.LOW) | |
if sys.argv[1] == 'forward': | |
GPIO.output(C, False) | |
GPIO.output(D, False) | |
elif sys.argv[1] == 'reverse': | |
GPIO.output(D, False) # set first | |
GPIO.output(C, True) | |
#GPIO.output(D, False) | |
elif sys.argv[1] == 'coast': | |
GPIO.output(C, False) | |
GPIO.output(D, True) | |
#elif sys.argv[1] == 'reverse2': | |
# GPIO.output(C, True) | |
# GPIO.output(D, True) | |
else: | |
print "unrecognized: %s" % (sys,argv[1],) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment