Reference for Wiring version 0024+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

Name

Encoder

Examples
#include "Encoder.h"

Encoder myEncoder;
int val;

void setup() {
  myEncoder.attach(2, 8);  // attach an ecoder to pins 2 and 3. 
}

void loop() {
  val = myEncoder.read();
}

Description Encoders are sensors used to track absolute or relative position. The Wiring Encoder library allows for easily manipulating shaft encoders. Encoders generate pulses when moved, on each pulse triggering an event on the Wiring I/O board, for this reason the phaseA pin of an encoder can only be connected to a Wiring pin capable of generating external interrupts. Four pins on the Wiring I/O board are capable of external interrupts for the Encoder library: pins 2, 3, 38 and 39, so only four encoders can be working at the a time.
Syntax
Encoder
Methods
attach()
detach()
write()
read()
attached()
Returns None
Usage Application
Updated on October 31, 2009 01:47:04pm PDT

Creative Commons License