Using the Motor Rotation Sensor



The Motor Rotation sensor is used to measure how far a motor has turned. A rotation sensor is built into the Medium Motor, the Large Motor, and the NXT Motor. The sensors in these motors can detect an amount of rotation in degrees. A full turn of a motor is 360 degrees of rotation.

You can also use the Motor Rotation sensor to find out what power level a motor is currently running at.
Tips and Tricks
A Motor Rotation sensor is used with a motor that is connected to a motor port on the EV3 Brick (A, B, C, or D). Motor Rotation sensors cannot be used with the EV3 sensor ports (1, 2, 3, and 4).
Motor Rotation Data
A Motor Rotation sensor can give the following data:
DataTypeNotes
Degrees NumericAmount of rotation in degrees
Rotations NumericAmount of rotation expressed in rotations (degrees/360, as a decimal number)
Current Power NumericCurrent motor power level if the motor is running (1-100), or 0 if the motor is stopped
Resetting a Motor Rotation Sensor
A Motor Rotation sensor can be reset to zero at any point in a program. The sensor will then measure the total amount of rotation relative to the reset point. To reset a Motor Rotation sensor, use the Motor Rotation block in the Reset mode.
Tips and Tricks
If you measure a Motor Rotation sensor that has never been reset, you will get the total amount of rotation that the motor has turned since the program started.
Motor Rotation Direction and Total Rotation
Forward rotation of a motor results in a positive number of degrees or rotations, and backward rotation results in a negative number. Rotation is always measured as the total amount of forward rotation since the sensor was last reset. Backward rotation is subtracted from any accumulated forward rotation.

The table below shows an example of motor actions happening in several steps and the result of measuring the motor rotation after each step.
StepActionMotor Rotation is then:
1Program starts, motor has not turned yet0 degrees
2Motor turns forward one full turn (360 degrees)360 degrees
3Motor turns forward one full turn again720 degrees
4Motor turns forward 60 degrees780 degrees
5Motor turns backward for 30 degrees750 degrees
6Motor Rotation is reset0 degrees
7Motor turns backward for 100 degrees-100 degrees
8Motor turns backward for 60 degrees-160 degrees
9Motor turns forward for 360 degrees200 degrees
Examples Using the Motor Rotation Sensor
Some examples of how you can use the Motor Rotation sensor in your program are shown below.
Example 1: Make a Sound when your Robot is Pushed
This program makes a robot make a sound when it is pushed by hand so that the wheels move a little bit. The program uses the Wait block in the Motor Rotations – Change – Degrees mode to wait for the rotation sensor for motor C to change by 5 degrees in either direction. Then a Sound block makes a sound.
Example 2: Drive in a Pattern for a Certain Distance
This program makes a robot drive straight for 2 rotations and then drive in a zigzag pattern for 6.5 total rotations. It drives in a zigzag pattern by moving first one wheel, then the other. The zigzag pattern is repeated in a Loop until motor B has driven a total of 6.5 rotations. The program uses the loop in the Motor Rotation – Rotations mode to stop the loop when the rotation sensor for motor B measures a total of 6.5 rotations. To make the 6.5 rotations measure only the zigzag driving, not including the 2 straight rotations in the beginning, the rotation sensor for motor B is reset to zero before the zigzag driving using the Motor Rotation block in the Reset mode.
Example 3: A Speed Control Dial
This program makes the motor connected to port C act like a speed control dial for the motor connected to port B. Turning the C motor forward and backward by hand will control the speed of the B motor. The program uses the Motor Rotation block in the Measure – Degrees mode to measure the degrees turned by motor C. This result is used for the Power input of a Large Motor block and also displayed using a Display block. The process is repeated in a Loop so that the speed is continuously updated.
Tips and Tricks
If the Power input to the Large Motor block is greater than 100, it will use 100% power.
Motor Rotation Blocks and Modes
The table below shows the programming blocks and modes that you can use with the Motor Rotation Sensor.
BlockModeUse
Wait Motor Rotation - CompareWait for a rotation sensor to reach a certain value (Degrees, Rotations, or Current Power).
WaitMotor Rotation - ChangeWait for a rotation sensor to change by a certain amount (Degrees, Rotations, or Current Power).
Loop Motor RotationRepeat a sequence of blocks until a rotation sensor reaches a certain value (Degrees, Rotations, or Current Power).
Switch Motor RotationChoose between two sequences of blocks based on a rotation sensor (Degrees, Rotations, or Current Power).
Motor RotationMeasureRead a rotation sensor (Degrees, Rotations, or Current Power), and get the result on a Numeric data wire.
Motor RotationCompareCompare a rotation sensor (Degrees, Rotations, or Current Power) to a threshold, and get the result on a Logic data wire.
Motor RotationResetReset a rotation sensor to zero.
Data LoggingSee Data Logging.
Tips and Tricks
Motor Rotation sensors are also used internally in the following Action blocks and modes:
BlocksModesUse
Medium Motor,
Large Motor
On for Degrees,
On for Rotations
Turn a motor by a certain number of degrees or rotations.
Move Steering,
Move Tank
On for Degrees,
On for Rotations
Drive using two Large Motors for a certain number of degrees or rotations.
Motor Rotation
Quick links