On Wed, 2 May 2018 21:51:08 -0700 (PDT), Mala Dies
<functt@gmail.com> declaimed the following:
import Adafruit_BBIO.GPIO as GPIO
import time
GPIO.setup("P9_21", GPIO.OUT)
GPIO.setup("P9_22", GPIO.OUT)
GPIO.setup("P9_12", GPIO.OUT)
GPIO.setup("P9_15", GPIO.OUT)
m1a = GPIO.output("P9_21", GPIO.HIGH)
m1a = GPIO.output("P9_22", GPIO.HIGH)
Meaningless assignments... First, the return from the second line
replaces the value returned by the first line, since you used the same name
for the return.
On the other hand -- based upon the documentation for the library,
GPIO.output() doesn't return anything so you are just replacing None with
None.
m1b = GPIO.output("P9_12", GPIO.HIGH)
m1b = GPIO.output("P9_15", GPIO.HIGH)
Ditto
You've set all control pins high -- which should, for any motor
controller I can envision, mean the motors are not powered (BTW -- you did
wire the ENABLE A and B pins to something, didn't you?
while (True):
try:
for motor in range (0, 101, 1): #starts at 0, steps up to
101 in 1 steps
m1a = ("P9_21")
Here you assign a string to the name, but you never do anything with
the string. So... again a meaningless assignment.
time.sleep(3)
print(motor)
And you never do anything with the motor pin itself, so nothing
changes.
This loop condenses down to just printing integers from 0..100 with a 3
second pause between them, and it does all of them before moving to the
next loop, which does the very same thing.
for motor in range (0, 101, 1):
m1a = ("P9_22")
time.sleep(3)
print(motor)
for motor in range (100, -1, -1):
m1b = ("P9_12")
time.sleep(3)
print(motor)
for motor in range (100, -1, -1):
m1b = ("P9_15")
time.sleep(3)
print(motor)
What behavior are you expecting since the above four loops are coded to
run on after the other -- nothing is being done in parallel even if you
were changing motor pin settings.
except(KeyboardInterrupt):
#And final cleanup
print "You have just ended your camp trip!"
GPIO.cleanup()
quit()
Your "final cleanup" will only be performed IF you hit <ctrl-c> BEFORE
the loops run out. Otherwise, you just fall off the end of the program with
no cleanup performed
My suggestion -- since you are using Python...
Open a shell and run Python in interactive mode, and then enter GPIO
statements one at a time setting pins to HIGH and LOW, in various
combinations, to see what it takes to activate the motors.
And, just for a giggle (untested as I don't have your hardware present)