While loop not exiting #10459
Unanswered
MrTinkerman
asked this question in
Using MicroPython
Replies: 1 comment 3 replies
-
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I have a fairly simple program to start and stop a motor, see below.
-- the motor is started and runs until both end stops go low (yes I have two end stops on the same side)
-- then it pauses and reverses
It seems to be working just fine but something stange is going on in this while loop:
If I put in time.sleep_ms(20) :
-- the values for the end stops are printed out correctly, although with a slight delay
-- the led is on while the loop runs and is turned off after the motor sequence
-- when triggering both end stops the loop exits and the motor stops and reverses
However, if I comment out time.sleep_ms(20) :
-- the values for the end stops keep being printed as 1 (triggering pulls them low)
-- the led behavior is the same
-- when triggering both end stops the loop seems to exit and the motor stops and reverses
And here's the thing: the print statement keeps running ?? Even while it seems the loop worked just fine.
I keep getting '1 1 ticks_ms' printed out indefinitely. The led is not turned on again so you would say the code in the loop is not running.
Then what is printing out over serial?
Does anyone have any idea what's going on here?
Thanks!
My code and info:
MicroPython v1.19.1 on 2022-06-18; Raspberry Pi Pico with RP2040
Thonny 3.3.13
Beta Was this translation helpful? Give feedback.
All reactions