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: 1 comment 4 replies

Comment options

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

@laurensvalk
Comment options

@trwhitt
Comment options

@laurensvalk
Comment options

Answer selected by laurensvalk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants