setEncoderPolarity()


Description

This function sets the count direction of an encoder.

Syntax

dcmotor.setEncoderPolarity(pol)

Parameters

pol - a integer value which represents count direction of an encoder

pol count direction
0 or grater than 0 normal (default)
otherwise invert

Returns

none

Example

#include <PhpocExpansion.h>
#include <Phpoc.h>

byte spcId = 1;

ExpansionDCMotor dcmotor(spcId, 1);

void setup() {
    Serial.begin(9600);
    while(!Serial)
        ;

    Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
    Expansion.begin();

    Serial.println(dcmotor.getPID());
    Serial.println(dcmotor.getName());

    dcmotor.setPolarity(1);
    dcmotor.setDirection(1);
    dcmotor.setPeriod(10000);
    dcmotor.setWidth(3000);

    //normal count direction
    dcmotor.setEncoderPolarity(0);
}

void loop() {

    Serial.println(dcmotor.getEncoderPosition());
    delay(100);
}