Hello Sir,
Seth here. Okay, I am getting it more slowly than I planned. You are
correct, the for loops do not hold some secret crest (they are not
magical). I understand. I came from a small background in another library
where similar software was typed up to fit the small library I was using.
In this case, no biggie.
Anyway, I used an if-else statement for programming this time. I am
starting to see, while this motor turns, what the different types of
software will do and how the changed set up will sit well or go against the
motor revolutions.
I am using sleep now instead of time.sleep, esp. since you let me know
about my import of sleep from time. If you want to look over this software
and reply, by all means, please do. If not, I understand. This software
created the motor to turn after initializing and then went into a rough
stop. Afterwards, the motor turned in the opposite direction. The program
ended and the motor stopped, i.e. unlike w/ the while loop and the for
loop. Oh, here is that odd software from my side:
import Adafruit_BBIO.GPIO as GPIO
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)
if EnA != GPIO.output("P9_21", GPIO.HIGH):
ln1 = GPIO.output("P9_22", GPIO.HIGH)
ln2 = GPIO.output("P9_12", GPIO.LOW)
sleep(2)
ln1 = GPIO.output("P9_22", GPIO.LOW)
ln2 = GPIO.output("P9_12", GPIO.HIGH)
sleep(2)
ln1 = GPIO.output("P9_22", GPIO.LOW)
ln2 = GPIO.output("P9_12", GPIO.LOW)
sleep(2)
print "I am here now!"
else:
for i in range(1, 9):
EnA = GPIO.output("P9_21", GPIO.HIGH)
ln1 = GPIO.output("P9_22", GPIO.LOW)
ln2 = GPIO.output("P9_12", GPIO.HIGH)
EnA = GPIO.output("P9_21", GPIO.HIGH)
ln1 = GPIO.output("P9_22", GPIO.HIGH)
ln2 = GPIO.output("P9_12", GPIO.LOW)
sleep(0.2)
EnA = GPIO.output("P9_21", GPIO.LOW)
ln1 = GPIO.output("P9_22", GPIO.HIGH)
ln2 = GPIO.output("P9_12", GPIO.HIGH)
sleep(0.2)
print "I am still almost there!"
try:
EnA = GPIO.output("P9_21", GPIO.OUT)
print "time.sleep(3)"
except(KeyboardInterrupt):
print "I got it over w/!"
GPIO.cleanup()
quit()
If you get tired of extra software correction, let me know. I can stop
sending over all this software and my lack of knowledge on Python, embedded
applications, and the BBB. But, if this still interests you, please reply.
I can always use more lessons and ideas.
Seth
P.S. Thank you for your time so far.
On Tuesday, May 8, 2018 at 7:15:24 PM UTC-5, Dennis Lee Bieber wrote:
>
> On Tue, 8 May 2018 11:43:56 -0700 (PDT), Mala Dies
> <[email protected] <javascript:>> declaimed the following:
>
> >Hello Mr. Dennis,
> >
> >Seth here. I made some other software that I want to try to describe to
> >you. Here goes it:
> >
>
> > 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)
>
> You still seem to think FOR loops do something magical -- but
> there is
> no data changing state inside these loops, so nothing changes during the
> looping. And you still have the meaningless assignments -- you aren't
> using
> the "labels" you created for the pins.
>
> Everything inside the WHILE loop condenses down to:
>
>
> GPIO.output(ENA, GPIO.HIGH) #motor enabled, stopped
> time.sleep(2)
> GPIO.output(IN1, GPIO.HIGH) #motor running, forward
> GPIO.output(IN2, GPIO.LOW) #NOP
> time.sleep(2*8) #range(1,9) is 1, 2, 3, 4, 5, 6, 7, 8
> GPIO.output(IN1, GPIO.LOW) #motor stopped, hard
> GPIO.output(IN2, GPIO.HIGH) #motor running, reverse
> time.sleep(2*6)
> GPIO.output(ENA, GPIO.LOW) #motor stopped, coasting
> time.sleep(2)
> print ...
> GPIO.output(ENA, GPIO.HIGH) #motor enabled, running,
> reverse
> time.sleep(1)
> GPIO.output(IN1, GPIO.HIGH) #motor stopped, hard
> GPIO.output(IN2, GPIO.LOW) #motor running, forward
> time.sleep(2)
> GPIO.output(ENA, GPIO.LOW) #motor stopped, coasting
> GPIO.output(IN1, GPIO.LOW) #motor still stopped
> GPIO.output(IN2, GPIO.LOW) #motor still stopped,
> all pins OFF
> time.sleep(2)
>
> Oh, and since you did "from time import sleep" you could replace
> all
> those "time.sleep" with just "sleep".
>
>
> --
> 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/35a5fe68-eaa0-47b9-a398-2d5b91894edc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.