© The LEGO Group
In this program, the robot will reverse direction when the sensor is pressed and beep when released. It will do this only once. The program will not respond to additional input from the sensor.
Note that here the motors stay on because there’s no command that turns them off.