back to AnalogEncoder
Description
This member function can be used to obtain the current counts for the associated AnalogEncoder object.
Parameters
None.
Returns
This function returns the current counts for an AnalogEncoder object as an integer.
Examples
#include <FEHIO.h> #include <FEHMotor.h> #define LOW_THRESH 0.15 #define HIGH_THRESH 2.20 int main(void) { //declares an analog encoder on P0_3 AnalogEncoder right_encoder(FEHIO::P0_3); //set the analog encoder threshold right_encoder.SetThresholds( LOW_THRESH, HIGH_THRESH ); //declares a motor on motor port 0 FEHMotor right_motor(FEHMotor::Motor0); //turn on the right motor to 75% power right_motor.SetPercent( 75.0 ); //ensure that the encoder counts are at zero by resetting right_encoder.ResetCounts(); //wait until the right encoder reaches 500 counts while(right_encoder.Counts() < 500); //stop the motor right_motor.Stop(); }