The V5 rotation sensor is a through-bore rotary encoder that uses the hall effect to measure the position, angle, and angular velocity of a rotating shaft passing through it.
Rotation sensors provide data with more accuracy and higher resolution compared to the integrated encoders in Motors, which makes them ideal for measuring rotating mechanisms like lifts, flywheels, and tracking wheels.
Creating a Rotation Sensor
Using the Peripherals struct passed to our main function, we can a Rotation Sensor from any one of the 21 SmartPort fields on it.
#[vexide::main]async fn main(peripherals: Peripherals) { let mut sensor = RotationSensor::new(peripherals.port_1);Create a Rotation Sensor on port 1.}