// Rotary encoder pins
const int ENCODER_DT = 19;
const int ENCODER_CLK = 20;
const int pinSW = 21;
// Variables to store current and previous rotary encoder state
volatile int encoderPos = 0;
volatile boolean encoderALast = HIGH;
volatile boolean encoderBLast = HIGH;
volatile int currentEncoderState = 0;
volatile int previousEncoderState = 0;
void setup() {
// Set encoder Setup modes
pinMode(ENCODER_DT, INPUT_PULLUP);
pinMode(ENCODER_CLK, INPUT_PULLUP);
pinMode(pinSW, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(ENCODER_DT), encoderA, RISING);//perhaps try to set to "low" as opposed to rising
attachInterrupt(digitalPinToInterrupt(ENCODER_CLK), encoderB, RISING);//perhaps try to set to "low" as opposed to rising
attachInterrupt(digitalPinToInterrupt(pinSW), onSwitchInterrupt, FALLING);
// Initialize serial communication
Serial.begin(9600);
}
void loop() {
}