Rotation Sensing#
To make Rotation Sensor blocks appear in VEXcode V5, a Rotation Sensor must be configured in the Devices window.
For more information, refer to these articles:
Set Rotation Sensor Position#
The Set Rotation Sensor Position block is used to set a Rotation Sensor’s current position to a defined value.
set [Rotation9 v] position to (0) degrees
The Set Rotation Sensor Position block accepts any positive or negative decimal or integer number.
Choose which Rotation Sensor to use.
In this example, the Rotation Sensor will print its starting position, set its position to -100 degrees, and then print the new position.
when started :: hat events
print ([Rotation9 v] position in [degrees v]) on [Brain v] ◀ and set cursor to next row
set [Rotation9 v] position to (-100) degrees
print ([Rotation9 v] position in [degrees v]) on [Brain v] ◀ and set cursor to next row
Rotation Sensor Angle#
The Rotation Sensor Angle block is used to report the Rotation Sensor’s current angle of rotation in degrees.
([Rotation9 v] angle in degrees)
The Rotation Sensor Angle block reports values in the range of 0.00 to 359.99.
Choose which Rotation Sensor to use.
In this example, the Rotation Sensor will print its starting rotation.
when started :: hat events
print ([Rotation9 v] angle in degrees) on [Brain v] ◀ and set cursor to next row
Rotation Sensor Position#
The Rotation Sensor Position block is used to report the current rotational position of the selected Rotation Sensor.
([Rotation9 v] position in [degrees v])
Choose which Rotation Sensor to use.
Choose what units the position will be reported in: degrees or turns.
In this example, the Rotation Sensor will print its starting position, set its position to -100 degrees, and then print the new position.
when started :: hat events
print ([Rotation9 v] position in [degrees v]) on [Brain v] ◀ and set cursor to next row
set [Rotation9 v] position to (-100) degrees
print ([Rotation9 v] position in [degrees v]) on [Brain v] ◀ and set cursor to next row
Rotation Sensor Velocity#
The Rotation Sensor Velocity block is used to report the current velocity of a Rotation Sensor.
([Rotation9 v] velocity in [rpm v])
Choose which Rotation Sensor to use.
Choose what units the position will be reported in: revolutions per minute (rpm) or degrees per second (dps).
In this example, the Drivetrain will drive turn to the right for 1 second before its current rotational velocity is printed on the Brain’s screen.
when started :: hat events
[Turn towards the right for 1 second.]
turn [right v]
wait (1) seconds
[Print the correct rotational velocity after 1 second.]
print ([Rotation9 v] velocity in [rpm v]) on [Brain v] ◀ and set cursor to next row