do you finally have a working rotary encoder? Could you pls share your code?
I'm trying to build a follow focus with a rotary on the remote control. The encoder information will be transmitted via UDP to a central unit.
I didn't get any eupts - what's wrong?
#define encoder0PinA 2
#define encoder0PinB 14
void setup() {
Serial.begin(115200);
//Set ENCODER
pinMode(encoder0PinA, INPUT_PULLUP);
pinMode(encoder0PinB, INPUT_PULLUP);
attachInterrupt(0, doEncoder, CHANGE);
}
void doEncoder() { //Read encoder and set manualy defined temperature.
if (digitalRead(encoder0PinA) == digitalRead(encoder0PinB)) {
Serial.println("+");
}
else {
Serial.println("-");
}
}
void loop() {
Serial.print(" ");Serial.print(byte(digitalRead(encoder0PinA)));
Serial.print(" ");Serial.println(byte(digitalRead(encoder0PinB)));
delay(1000);
}
Gerhard