It's time to get back into control... with the gamepad blocks.
The gamepad blocks allow you to control a program, and therefore your robot with the gamepad. The block enables this type of function by returning a Boolean (true/false) value based on whether or not a button is pressed. All blocks from the Gamepad section of the Block Library must be placed inside a Repeat While True loop so that the commands repeat indefinitely.
The Gamepad (Buttons) block must also be used in conjunction with an If statement. The statement returns a True value if the assigned button is pressed. It is desirable that an If/Else block is used.
The gamepad has 12 different buttons which can either be pressed (true/1) or not pressed (false/0).
The default value (not pressed) of a button is 0 or false. When pressed, the value of that button is 1 or true.
The following is one example of how to apply the Gamepad (Buttons) block to a program:
- Add an If block into a repeat-while-true loop.
- Add the Gamepad (Buttons) block to the if statement.
- Use the central and right drop-down menus to assign a button to the gamepad block. Use the left drop-down menu to select the gamepad used, if necessary.
When the program below executes, pressing the B button causes the robot to drive forward for 1 second.
Select the desired gamepad.
Select the type of button (dpad, bumper, stick, action).
(refer to the image at the top of the page)
|Button||Select the desired button.|