Connection to gyroscopic sensor


This object represents a connection to a single-axis EV3 Gyro Sensor (item number 45505). To connect to an gyroscopic sensor, create this object using the gyroSensor function. To measure total rotation or rate of rotation, use this object with the functions listed in Object Functions.


Before creating an object, complete the steps described in Connections to EV3 Hardware.

Use legoev3 to connect to, and create an object that represents, the EV3 brick. For example:

myev3 = legoev3;

Use gyroSensor to connect to, and create an object that represents, a gyroscopic sensor. For example:

mygyrosensor = gyroSensor(myev3)
mygyrosensor = 

  gyroSensor with properties:

    InputPort: 2

To get data from the sensor, use the gyroSensor object with readRotationAngle, readRotationRate, and resetRotationAngle. For example:

ans =



expand all

This property is read-only.

Number of the EV3 input port that the sensor uses, returned as a double.

Example: 1

Data Types: double

Object Functions

gyroSensorCreate connection to gyroscopic sensor
readRotationAngleRead rotation angle from gyroscopic sensor
readRotationRateRead rotation rate from gyroscopic sensor
resetRotationAngleReset rotation angle to zero