Libraries
\ Encoder
Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.
Name |
Encoder |
Examples |
#include <Encoder.h>
int val;
Encoder myEncoder;
void setup() {
myEncoder.attach(EI2, 8);
myEncoder.write(0);
Serial.begin(9600);
}
void loop() {
val = myEncoder.read();
Serial.print("Encoder is at: ");
Serial.println(val);
delay(100);
}
|
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. On Wiring v1 boards the external interrupts capable pins are: 0, 1, 2, 3, 36, 37, 38 and 39 named EI0, EI1, .. EI7 respectively. On Wiring S board the external interrupts capable pins are: 2, 3 and 18 named EI0, EI1 and EI2 respectively. |
Syntax |
Encoder
|
Methods |
|
Returns |
None |
Usage |
Application |
Updated on July 07, 2011 11:09:54pm PDT