Reference for Wiring version 0027+. 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.

Class

Encoder

Name

detach()

Examples
#include "Encoder.h"

Encoder myEncoder;
int position;

void setup() {
  // attaches a encoder with phaseA connected 
  // to pin 2 and phaseB connected to pin 8
  myEncoder.attach(2, 8);  
}

void loop() {
  if(myEncoder.attached()) {
    position = myEncoder.read();  // read the encoder position 
    myEncoder.detach();           // detach the encoder
  }
}

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 September 16, 2010 09:19:20pm PDT

Creative Commons License