upm  1.3.0
Sensor/Actuator repository for libmraa (v1.7.0)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions
RotaryEncoder Class Reference

API for the Grove Rotary Encoder. More...

Detailed Description

UPM module for the Grove rotary encoder. This rotary encoder encodes a rotation signal into electronic pulses that can be used to measure rotation and direction. It is useful in cases where a rotary knob is required, but using a potentiometer is not desirable. A rotary encoder can turn a full 360 degrees without a stop and does not place a resistive load on the circuit, as is the case with a potentiometer.

This module maintains a position that is incremented or decremented according to the rotation on the encoder.

// Instantiate a Grove Rotary Encoder, using signal pins D2 and D3
upm::RotaryEncoder* rotaryencoder = new upm::RotaryEncoder(2, 3);
while (shouldRun)
cout << "Position: " << rotaryencoder->position() << endl;

Public Member Functions

 RotaryEncoder (int pinA, int pinB)
 ~RotaryEncoder ()
void initPosition (int count=0)
int position ()

Constructor & Destructor Documentation

RotaryEncoder ( int  pinA,
int  pinB 

RotaryEncoder constructor

pinADigital pin to use for signal A
pinBDigital pin to use for signal B

RotaryEncoder destructor

Here is the call graph for this function:

Member Function Documentation

void initPosition ( int  count = 0)

Resets the position to a given number; default is 0.

countInteger to initialize the position to

Here is the call graph for this function:

int position ( )

Gets the position value

Here is the call graph for this function:

The documentation for this class was generated from the following files: