Using the Brick Buttons



The Brick Buttons are the five buttons (Left, Centre, Right, Up, and Down) on the face of the EV3 Brick. You can use the Brick Buttons like a sensor to detect if a button is pressed, and to find out which button is pressed.

You can use the Brick Buttons to make your program respond to button presses. For example, you could make a robot arm lift up and down when the Up and Down buttons are pressed.
Tips and Tricks
The Back button on the EV3 is not included in the Brick Buttons. Pressing the Back button aborts a running program.
The Brick Buttons can also keep track of whether a button has been pressed and then released in the past. This is called Bumped, and it works the same as the Bumped state of the Touch Sensor. See Understanding Bumped Using the Touch Sensor – for more information.
Brick Buttons Data
The Brick Buttons can give the following data:
DataTypeNotes
Button ID NumericIndicates which button is currently pressed:
0 = None
1 = Left
2 = Centre
3 = Right
4 = Up
5 = Down
Pressed LogicFor a specified Button ID (1-5), True if the button is pressed, False if not.
Released LogicFor a specified Button ID (1-5), False if the button is pressed, True if not.
Bumped LogicFor a specified Button ID (1-5), True if the button has been pressed and released in the past. The next Bumped occurrence will then require a new press and release.
Tips and Tricks
The Brick Buttons cannot detect when more than one button is pressed at the same time. If you press two buttons at the same time, one button will override the other.
Examples Using the Brick Buttons
Some examples of how you can use the Brick Buttons in a program are below.
Example 1: Press a Button to Continue
This program makes a robot drive forward for one second, then it displays “Press a Button…”. It then waits for one of the Brick Buttons to be pressed before driving backward for one second. The program uses the Wait block with the Brick Buttons - Change mode to wait for any brick button to be pressed.
Example 2: A Brick Buttons Control Panel
This program makes a robot turn left when the Left button is pressed, and turn right when the Right button is pressed. The program uses a Switch block with the Brick Buttons - Measure mode to find out which of the Brick Buttons is pressed. The three different cases in the Switch make the robot: turn left when the Left button is pressed, turn right when the Right button is pressed, and stop when no button is pressed. The test is repeated continuously in a Loop.
Tips and Tricks
Try using the “+” button on the Switch to add more cases. For example, you might make the robot drive forward and backward when you press the Up and Down buttons.
Example 3: Control the Brick Status Light Colour with the Brick Buttons
This program turns the Brick Status Light on in green when you press the Left button, in orange when you press the Centre button, and in red when you press the Right button. First, it uses a Switch block in the Brick Buttons - Compare mode to test whether the Left, Centre, or Right button is pressed. If not, a Brick Status Light block turns the light off. If one of the three buttons is pressed, a Brick Buttons block in Measure mode gets the Button ID of the pressed button (1-3) on a Data Wire. A Mathematics block then subtracts 1 from this value so that it can be used as the Colour input (0-2) to the Brick Status Light block.
Brick Buttons Blocks and Modes
The table below shows all of the programming blocks and modes that you can use with the Brick Buttons.
BlockModeUse
WaitBrick Buttons – CompareWait for one of the selected Brick Buttons to be Pressed, Released, or Bumped.
WaitBrick Buttons – ChangeWait for the pressed Brick Button (Button ID) to change. If no Brick Button is pressed at the start of the block, this will wait for any Brick Button to be pressed.
LoopBrick ButtonsRepeat a sequence of blocks until one of the selected Brick Buttons is Pressed, Released, or Bumped.
SwitchBrick Buttons - MeasureChoose between two or more sequences of blocks depending on which Brick Button is pressed.
SwitchBrick Buttons - CompareChoose between two sequences of blocks depending on whether one of the selected Brick Buttons is Pressed, Released, or Bumped.
Brick ButtonsMeasureGet the Button ID of the currently pressed Brick Button (0 if none is pressed) on a Numeric data wire.
Brick ButtonsCompareTest whether one of the selected Brick Buttons is Pressed, Released, or Bumped, and get the result on a Logic data wire.
Brick Buttons
Quick links