#### Event triggered when a button is pressed onevent buttons # Button forward is pressed, so increase speed when button.forward == 1 do speed += 50 call math.min(speed, speed, 500) end # Button backward is pressed, so decrease speed when button.backward == 1 do speed -= 50 call math.max(speed, speed, -300) end # Button center is pressed, so stop the robot when button.center == 1 do speed = 0 motor.left.target = 0 motor.right.target = 0 end