Quote:
Originally Posted by Maxchrist
we are trying to sense position. we have it on an a and b channel plugged into the digital i/0 on port 1 and 2.
|
This is not the proper wiring to use the encoder as an absolute sensor (position). Refer to the last section of Joe Ross's link.
[ edit ]
Provided you
do want to use it as a quadrature, though, you would first create a new Encoder object:
Code:
Encoder encoder = new Encoder(aChannel, bChannel);
Then enable it:
Then, you would read it like so:
Code:
encoder.getDistance();
Depending on the application, you may also want to calibrate the distance per pulse:
Code:
encoder.setDistancePerPulse(someConstant);