Frequently Asked Questions
Mon-Fri, 9am to 5pm
U.S. Mountain Time:
Chat With Us
March 11, 2013
about 2 years ago
I had similar problem as the other users and didn’t manage to use this encoder by using libraries or example code. After a few nights failing to implement existent code I decided to go reverse engineering and figure out what kind of output this thing was giving, and I came out with this code that is working nice with all the units I have (a bought a bunch of them with ringcoder breakouts and everything). This code adds or subtracts from encoderPosition every time the encoder reachs a detent. It will still fail to detect 1% of the times you reach a detent. I used port 52 and 53 since I’m testing this on Arduino DUE (all pins can be used as interrupts), but if you are using other arduinos you should use external interrupt pins.
int aPin = 52; //connected to the A port
int bPin = 53; //connected to the B port
digitalWrite(aPin, HIGH); //pulled-up
digitalWrite(bPin, HIGH); //pulled-up
attachInterrupt(aPin, readEncoder, CHANGE);
attachInterrupt(bPin, readEncoder, CHANGE);
signed int encoderPosition;
volatile char rotaryData = 0x0;
No public wish lists :(
Forgot your password?
No account? Register one!