Running code simultaneously #962
Unanswered
JobadSayas
asked this question in
Q&A
Replies: 1 comment
-
https://pybricks.com/projects/sets/mindstorms-robot-inventor/main-models/gelo/remote/ is a good example of using generator functions to do multiple things at the same time. It is monitoring remote control button presses, controlling motors and controlling lights all at the same time. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to do something like a police patrol controlled by remote.
I am using Move Hub and have lights. So I do have already the code to move the car with the remote, and the lights turn on and off when pressing one of the buttons.
I wanted the lights to blink similar to a patrol, so I used a while loop, but when running the while loop, the rest of the code gets unaccessible, I cannot move the car anymore with the remote, I was algo hoping to turn on and off the blinking lights with the remote but the program gets stocked in the while.
So is there a way to have some sort of a multitask? I mean running at least two task a the same time, meaning the blinking while still using the remote?
I was able to do something similar with Powered Up app for iPad, so I was able to stop the while loop with the remote. I had a variable to toggle on and off the lights, then a do while the variable was True and I was able to control the car with the remote and to change the value of the variable to turn off.
Is there a way to do this with pybricks?
I have this issue with the blinking lights, but was hoping to do other stuff using the same concept, just being able to run a loop while something else is happening.
Hopefully somebody can help, really appreciate the help. Regards
Beta Was this translation helpful? Give feedback.
All reactions