UPM

The UPM API is a high level sensor library for IoT devices using MRAA. See examples here. Back to index page.
SparkFun sensor images provided under CC BY-NC-SA-3.0.

RotaryEncoder Class

Module: rotaryencoder

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.
rotaryencoder.jpg

Item Index

Methods

RotaryEncoder

(
  • pinA
  • pinB
)
Number

RotaryEncoder constructor

Parameters:

  • pinA Number

    Digital pin to use for signal A

  • pinB Number

    Digital pin to use for signal B

Returns:

Number:

initPosition

(
  • count
)

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

Parameters:

  • count Number

    Integer to initialize the position to

position

() Number

Gets the position value

Returns:

Number: