Is it possible to program a robot to start but stop whenever?

I do not want it to go in succession, e.g.: how many rotations it takes until I can press it. I want it to be stopped whenever. The repeat until and if command blocks do not seem to work. Is it possible to do this? If so, what programming blocks do I need?

Tried using set mult . motors, but it needs a trigger like wait until the button is pressed. I want the robot to keep running after the button is pressed but stop if the touch led or button is pressed again.

Yes, you can do this. The most trivial way is to embed everything in if statements and keep each block short. For example, with pseudo code, let’s say you start with this:

driveForward(20 rotations, 64 speed)
turnRight(90 degrees, 64 speed)
driveForward(10 rotations, 64 speed)

You could change to:

boolean endProgram = false
repeat 80 times {
if (buttonPress = true) {endProgram = true}
if (endProgram = false) {driveForward(0.25 rotations, 64 speed)}
}
repeat 30 times {
if (buttonPress = true) {endProgram = true}
if (endProgram = false) {turnRight(3 degrees, 64 speed)}
}
repeat 40 times {
if (buttonPress = true) {endProgram = true}
if (endProgram = false) {driveForward(0.25 rotations, 64 speed)}
}

You can see the premise here. It keeps checking for buttonPress. When buttonPress is found, endProgram becomes true. Once endProgram becomes true everything else gets skipped.

Now, I don’t love it as I’ve written it because the motion will be really jerky. Look at the first loop. It drives forward a tiny bit, then stops and checks, then more forward, stop and check, … A better thing to do is to set motors ahead of time if you haven’t ended the program and then have a delay that repeats. The delay watches either for the button to be pressed or a certain encoder count to be reached. When you get there, it exits.

That should give you a few ideas how you can approach things. The specifics will probably depend on your programming environment.