Main Content

Gamepad Accelerometer

Read analog value from VEX gamepad accelerometer

Add-On Required: This feature requires the Simulink Coder Support Package for ARM Cortex-based VEX Microcontroller add-on.

  • Gamepad Accelerometer block

Simulink Coder Support Package for ARM Cortex-based VEX Microcontroller / Gamepad


The Gamepad Accelerometer block is used to read an analog value from the VEX® gamepad accelerometer based on the axis of rotation (x or y) of the gamepad.

The output for this block ranges from –128 to 127. There are two accelerometers on the VEX gamepad, and their axes are aligned perpendicular to each other. Rotation of the VEX gamepad along either the horizontal axis (1) or the vertical axis (2) results in an output value in the range –128 to 127. You can use this analog value to control peripherals, such as a DC motor, that are connected to the VEX microcontroller.



expand all

Connect a source block such as the Gamepad Simulator block from the Utilities library in Simulink® Support Package for ARM® Cortex®-based VEX Microcontroller.


This port appears only when you select the Add input port for simulation parameter.

Data Types: double


expand all

The block output ranges from –128 to 127 based on the axis selected and the orientation of the gamepad.

During simulations, without the hardware, this block emits zeroes if there is no Source block connected the simulation input port (see Block Produces Zeros or Does Nothing in Simulation).

Data Types: double


expand all

This parameter is read only. You can have a pair of VEX gamepads to control the peripherals connected to the VEX microcontroller. However, in the VEX Robotics and BEST Robotics competitions, teams are allowed only one gamepad. Therefore, Joystick is set to 1 by default, and it cannot be changed.

The axis of rotation determines which accelerometer is used to generate the output value. Select 1 for the horizontal x-axis and 2 for the vertical y-axis.

Select this check box to add an input port to specify an analog value for acceleration.

How often the Gamepad Accelerometer block should read the values from the gamepad, specified in seconds. The default value is 0.02 seconds.

If you select the Add input port for simulation check box, the Sample time parameter is hidden and its value is inherited.

Extended Capabilities

Version History

Introduced in R2016a