.ResetCounts( )

back to DigitalEncoder

Description

This function is used to reset the counts to zero for a DigitalEncoder object.

P3_6 and P3_7 cannot be used for digital encoders!!

Parameters

None.

Returns

None.

Examples

#include <FEHIO.h>
#include <FEHMotor.h>

int main(void)
{
    //declares a digital encoder on P0_3
    DigitalEncoder right_encoder(FEHIO::P0_3);

    //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();
}