[Tutor] (no subject)
Alan Gauld
alan.gauld at yahoo.co.uk
Tue Apr 5 05:18:37 EDT 2022
On 04/04/2022 23:02, Megan Ani Mirkhanian wrote:
> the stepper motor to go backwards and then forwards. I am trying to find a
> way to make the two for loops variables so that when I want to make the
> stepper motor go backwards I click on for instance x and enter and when I
> want the stepper motor to go forward I click on for instance y and enter.
I'm not clear about what you want to know.
Is it how to build a UI that responds to clicks?
If so what kind of UI do you need? A CLI (aka terminal)
or a GUI or a web page? All are possible but all are
quite different.
Or is it how to switch between forward and backwards motion based on
whether x or y is set?
In fact I'd suggest a single variable called 'direction' and set it
to 'forward' or 'backward'. Alternatively use a boolean variable
called forward and set that to True or false.
Then you can write
if forward:
for _ in range(256); forwardStep()
else:
for _ in range(256): backwardStep()
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list