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.

Class

Encoder

Name

detach()

Examples
#include <Encoder.h> 
 
int position; 
Encoder myEncoder; 
 
void setup() { 
  // ataches the encoder to pins EI2 and pin 8
  // EI2 is pin 18 on Wiring S
  // EI2 is pin 2 on Wiring v1
  myEncoder.attach(EI2, 8); 
  myEncoder.write(0); // set the encoder position to 0
} 
 
void loop() { 
  if (myEncoder.attached()) {
    // read the encoder position
    position = myEncoder.read();  
    // detach the encoder 
    myEncoder.detach();
  }
}
Description The detach() method detaches an Encoder variable from the pins used to attach the encoder.
Syntax
encoder.detach()
Parameters
encoder The Encoder variable
Returns None
Usage Application
Updated on July 07, 2011 11:09:55pm PDT

Creative Commons License