There are only three fundamental types of sensors.
Analog sensors include, potentiometers, gyro and line sensors. To read an analog sensor use the vexAdcGet function.
This returns a 12 bit value in the range 0 to 4095.
The analog inputs are constantly being scanned, vexAdcGet returns the latest value. The sample rate for each analog input in ConVEX is 13.4KHz.
Digital sensors need to be configured before they can be used, by default; all digital pins are set to be inputs. To change the type of a digital pin the digital configuration structure is used, see the configuration page for details.
Simple digital sensors such as bump switches can be read using the vexDigitalPinGet function.
vexDigitalPinGet(tVexDigitalPin pin)
Control of LEDs and pneumatics is done using the vexDigitalPinSet function.
vexDigitalPinSet(tVexDigitalPin pin, tVexDigitalState state)
Complex digital sensors have dedicated functions to read them; they also need to be configured correctly before use.
vexSonarGetCm(tVexSonarChannel channel)
vexSonarGetInch(tVexSonarChannel channel)
Sonars can read in either cm or inches regardless of the way they were originally configured.
vexEncoderGet(int16_t channel)
Encoder data is returned as a 32 bit signed value.
Encoders can be set using the vexEncoderSet function, non zero values are allowed.
vexEncoderSet( int16_t channel, int32_t value );
The only smart sensors that are currently available are the Integrated Motor Encoders (IMEs).
vexImeGetChannelMax() can be used to find the number of IMEs attached to the cortex.
To read an individual IME
vexImeGetCount(int16_t channel)
IMEs or quadrature encoders can be assigned to a motor for position feedback, this is done using the motor configuration structure, see the configuration page for details. When an encoder is assigned to a motor is may be read using the following function.