Hey all! I am teaching a class in Middle School and a student is working on a project with a bumper switch. I’ll attach the code here below. The bumper switch work when we use the control “When Bumper switch pressed” but does not work when we use the “if bumper pressed” control code in the middle of the code. That shows me the device is working but the code isn’t. Any solutions?
I believe this is because an [if, then] block only checks if the condition (Bumper is pressed in this case) once, while a [when bumper is pressed] hat block will wait until the bumper is pressed to run whatever code is attached to it.
So, in the example you showed, it will perform the first command (spin mopey…) and then check if the bumper is pressed. If it is pressed at that moment, then it will execute the commands in the C block, but otherwise nothing will happen and that will be the end of this project.
Doesn’t when started only run once? I don’t really know blocks, but if there’s a block called “when user control” or “when driver control” or something similar, try putting your code in there.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.