getEncoderPosition()


Description

This function gets the counter value of an encoder.

Syntax

dcmotor.getEncoderPosition()

Parameters

none

Returns

the current counter value of an encoder

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.setPeriod(10000);
    dcmotor.setWidth(3000);
}

void loop() {
    // get the counter value of an encoder
    Serial.println(dcmotor.getEncoderPosition());
    delay(100);
}