Knowledge Base

Gamepad (Triggers) Block

It's time to get back in control... with the gamepad blocks.

The Gamepad (Trigger) block allows you to control the motors and servos of your robot with the gamepad. This block enables this type of function by providing the motor or servo blocks with values from the actual input from the pad. 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 (Triggers) block returns a value based on the position of either the left or right gamepad trigger. This value can be assigned to a Single Motor block for example to rotate the motor based on the extent to which the trigger is pressed.

 

The default value (not pressed) of a trigger is 0. The values can range from 0 to 1, depending on how much the trigger is pressed. Because of the base range of the values, the values should be multiplied by 100 using a numerical operator block in order to extend the range to 0 to 100, which allows for better control of motor blocks, whose range is -100 to 100.  

To apply the gamepad (triggers) block to a program:

  1. Add a motor or servo block into a Repeat While True loop.
  2. Add a Numerical Operator block to one of the parameters (or the single parameter) of the motor block.  
  3. Add the Gamepad (Triggers) block to the first slot of the numerical operator. 
  4. Use the right drop-down menu to assign the desired trigger. Use the left drop-down menu to select the gamepad being used, if necessary. 
  5. Using the numerical operator and a numerical data block, multiply the value of the gamepad (triggers) block by 100. 

 

Example Program

When this program executes, pulling the left trigger controls the left motor, and pulling the right trigger controls the right motor. 

Configuration

Parameter Configuration
Get gamepad

Select the desired gamepad.

Trigger

Select the desired trigger (left/right).

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

Please sign in to leave a comment.

Powered by Zendesk