Hello Mr. Dennis,
Seth here. I made some other software that I want to try to describe to
you. Here goes it:
import Adafruit_BBIO.GPIO as GPIO
import time
from time import sleep
EnA = "P9_21"
ln1 = "P9_22"
ln2 = "P9_12"
print "Initialize"
GPIO.setup("P9_21", GPIO.OUT)
GPIO.setup("P9_22", GPIO.OUT)
GPIO.setup("P9_12", GPIO.OUT)
GPIO.output("P9_21", GPIO.LOW)
GPIO.output("P9_22", GPIO.LOW)
GPIO.output("P9_12", GPIO.LOW)
while True:
for i in range(1):
EnA = GPIO.output("P9_21", GPIO.HIGH)
time.sleep(2)
for i in range(1, 9):
ln1 = GPIO.output("P9_22", GPIO.HIGH)
ln2 = GPIO.output("P9_12", GPIO.LOW)
time.sleep(2)
for i in range(1, 7):
ln1 = GPIO.output("P9_22", GPIO.LOW)
ln2 = GPIO.output("P9_12", GPIO.HIGH)
time.sleep(2)
for i in range(1):
EnA = GPIO.output("P9_21", GPIO.LOW)
time.sleep(2)
print "Go, Go Bananas!"
for i in range(1):
EnA = GPIO.output("P9_21", GPIO.HIGH)
time.sleep(1)
for i in range(1):
ln1 = GPIO.output("P9_22", GPIO.HIGH)
ln2 = GPIO.output("P9_12", GPIO.LOW)
time.sleep(2)
for i in range(1):
EnA = GPIO.output("P9_21", GPIO.LOW)
ln1 = GPIO.output("P9_22", GPIO.LOW)
ln2 = GPIO.output("P9_12", GPIO.LOW)
time.sleep(2)
try:
print "Um...what is happening?"
time.sleep(2)
except(KeyboardInterrupt):
print "I got it over w/!"
GPIO.cleanup()
quit()
Okay...
This software imports a library. Got this fact. I then import time and
sleep "If I choose to use it later" from time.
Then, I label my pins for future software.
Then, I set up my GPIO and then I set those pins as outputs (all LOW for
initialization). Then, I a set up a while loop and while those facts are
true, it runs.
The software states...
The EnA pin starts, w/ a HIGH, the motor and turns it on.
Then, the software sleeps (pauses) and I run one motor one direction and
then the software goes into hibernation. Then...
The software runs the motor the opposite direction and then pauses. The
EnA pin runs LOW and halts the motor from going any direction.
Then, the EnA pin runs HIGH once more. This creates the motor to
initialize. Then, I run the motors one more time in one direction.
Then, I run all pins LOW to halt the motor and create all leads to
understand that it is in stop mode.
Seth
P.S. Although this is a ton of "then...then...then," I think I am starting
to understand more. You have helped greatly. If this is not such an
annoyance, do not hesitate to reply. If you are done w/ me and this
conversation, please just kindly let me know. Thank you, sir.
On Sunday, May 6, 2018 at 8:46:45 PM UTC-5, Dennis Lee Bieber wrote:
>
> On Sun, 6 May 2018 14:20:17 -0700 (PDT), Mala Dies
> <[email protected] <javascript:>> declaimed the following:
>
>
> >while True:
> >
> > for i in range(10):
> > EnA = GPIO.output("P9_21", GPIO.HIGH)
>
> 1) the variable names on the left of useless as they are
> never
> referenced anywhere else in the code.
>
> 2) this loop just sets the pin to the SAME VALUE 10 times
> in a row.
>
> > for i in range(3):
> > ln1 = GPIO.output("P9_22", GPIO.HIGH)
>
> 3 times, same value
>
> > for i in range(5):
> > ln2 = GPIO.output("P9_12", GPIO.HIGH)
>
> 5 times...
>
> > for i in range(4):
> > ln1 = GPIO.output("P9_22", GPIO.LOW)
>
> 4 times...
>
> > for i in range(10):
> > EnA = GPIO.output("P9_21", GPIO.LOW)
> > print "Go, Go Bananas!"
>
> 10 times, with a repeated print statement.
>
>
> The total effect condenses down to (and to make it more clear, I'm
> going to set up "constants" for the pins):
>
> ENA = "P9_21"
> IN1 = "P9_22"
> IN2 = "P9_12"
> # I'm presuming the default startup state is all GPIO's LOW, but
> one
> #should check the documentation for the BBB to confirm
> while True:
> GPIO.output(ENA, GPIO.HIGH) #enable motor control, motor in
> STOP
> time.sleep(0.1) #or however long 10 calls to GPIO_output
> consume
> GPIO.output(IN1, GPIO.HIGH) #motor running FORWARD
> time.sleep(0.03) #or however long 3 calls takes to execute
> GPIO.output(IN2, GPIO.HIGH) #motor in STOP
> time.sleep(0.05) #or whatever 5 calls takes
> GPIO.outputIN1, GPIO.LOW) #motor running REVERSE
> time.sleep(0.04) #or whatever 4 calls takes
> GPIO.output(ENA, GPIO.LOW) #motor coasting to stop
> time.sleep(0.2) #assumes 10 calls and 10 prints
>
> Note that, since the state was REVERSE when you disabled control,
> the
> next pass of the loop will START in REVERSE when you enable control. THEN
> when you set IN1 to HIGH, the motor will go to hard stop (since IN2 is
> still HIGH from the first time through the loop). It will stay in STOP
> until you set IN1 to LOW, when it again will run in REVERSE until the ENA
> is turned off.
>
>
> --
> Wulfraed Dennis Lee Bieber AF6VN
> [email protected] <javascript:>
> HTTP://wlfraed.home.netcom.com/
>
>
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/beagleboard/67195585-34cf-4ad8-b6f2-d473cb745433%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.