Lucas
Lucas

Reputation: 1

RobotC Mindstorms EV3 - How to get Brick Button Input?

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.

Upvotes: 0

Views: 473

Answers (1)

ChilliPenguin
ChilliPenguin

Reputation: 715

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
  }
}

Upvotes: 0

Related Questions