Skip to content

How to stop on ongoing motor motion using another condition? #1621

Answered by laurensvalk
laurensvalk asked this question in Q&A
Discussion options

You must be logged in to vote

Another way of phrasing this more systematically, is to say we want to rotate the motor

  • until it reaches 3600 degrees; or
  • until it gets stuck/stalled; or
  • until the sensor sees an obstacle...

... whichever comes first.

There are a few solutions.

The easy way with Pybricks

You can implement this quite literally with the multitask block, and set it to complete when one task finishes:

It will do three tasks at once: rotate, wait for stall, and wait for sensor. It completes when one of them completes, which is exactly what we wanted!

Then the program continues with the rest, which is just a sound in this case.

The hard way 1 (synchronously using classic apps/solutions)

In the classic soluti…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
4 replies
@trwhitt
Comment options

@laurensvalk
Comment options

laurensvalk Nov 2, 2024
Maintainer Author

@trwhitt
Comment options

@laurensvalk
Comment options

laurensvalk Nov 4, 2024
Maintainer Author

Answer selected by laurensvalk
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants