-
Notifications
You must be signed in to change notification settings - Fork 0
Using the Sensor Struct
This library provides the sensor
structure for VEX sensors which makes monitoring their speed and values much more simple.
Define and initialize a sensor
within your code like the example below:
sensor sensor_name;
initializeSensor(&sensor_name, scaling_factor, sensor_port [, &PID]); //PID is optional.
The ampersand is necessary.
-
sensor_port
is what port that this sensor is bound to (i.e. in1, dgtl1, I2C_1). -
scaling_factor
is a float that will be multiplied by the raw sensor value, so if you want to convert the raw value into something more meaningful (i.e. degrees), do that here. -
PID
is an optional parameter which is a pointer to a struct of typepid
that defines the constants for a PID control. Include this if you plan on using this sensor within a PID control. If it is not included, all constants will be initialized as 0. Read more about a PID control here.
Within any loop where you want to access this sensor's value, call updateSensorValue(&sensor_name)
. This structure will not work without this function call. Then, you can access the speed and value of the sensor using sensor_name.speed
and sensor_name.val
, respectively. Value is equal to the raw sensor value times the scaling factor, and speed is in terms of units (as defined by the scaling factor) per second.
Beginner Features:
Intermediate Features:
Advanced Features:
Controlling the LCD
Using Autonomous Modes
Custom Pre Auton Procedure
Using Autonomous Modes in User Control
More Remote Functionality
Configuring Bailout Button
Custom User Control Procedure
PID Control
Drive Train Control