RobotC Mindstorms EV3 - How to get Brick Button Input?

377 views Asked by At

Is anyone able to tell me how to get input from the brick buttons on the LEGO Mindstorms EV3 brick using the ROBOTC program ('ROBOTC for LEGO Mindstorms 4.X') that I can use in a script? The program gives me suggestions when I type in 'button', like 'buttonLeft' and 'BUTTONTYPE'. I was thinking that it should be possible because I can find numerous tutorials that use the LEGO Mindstorms Education EV3 Student Edition, but none that are using RobotC.

1

There are 1 answers

0
ChilliPenguin On

buttonLeft and in general the Buttontypes are enums for the getButtonPress function. If you want to get input, you will have to use a while loop with and check for the buttons status per iteration.

while(true){
  if(getButtonPress(buttonUp)) {
    //runs code here every iteration the top button is down
  }
}