Library to handle a quadrature encoder with interrupts

Dependents:   Sensor

Embed: (wiki syntax)

« Back to documentation index

RotaryEncoder Class Reference

RotaryEncoder Class Reference

Class to handle a rotary encoder The lib is interrupt based, therefore no update functions have to be called. More...

#include <Encoder.h>

Public Member Functions

int position ()
 Returns the overall position of the encoder.
int delta ()
 Returns the encoders change since the last call to this function.

Detailed Description

Class to handle a rotary encoder The lib is interrupt based, therefore no update functions have to be called.

Example usage:

  #include "mbed.h"
  #include "Encoder.h"

  RotaryEncoder encoder(D3, D4);

  int main()
  {
      while(1)
      {
          int pos = encoder.position();
          wait(1.0f);
      }
  }

Definition at line 24 of file Encoder.h.


Member Function Documentation

int delta (  )

Returns the encoders change since the last call to this function.

Definition at line 45 of file Encoder.h.

int position (  )

Returns the overall position of the encoder.

Definition at line 39 of file Encoder.h.