Hi everyone,
Here's an age old question about this encoder.h library: what is the proper way to use this library with interrupts with a quadrature encoder pot/knob..
There are clear examples of how to use it by polling.... but the library has a lot of provision for interrupts and how to implement them on the T3.2 evades me..
Thank you in advance.
Here's what I've put together so far:
Here's an age old question about this encoder.h library: what is the proper way to use this library with interrupts with a quadrature encoder pot/knob..
There are clear examples of how to use it by polling.... but the library has a lot of provision for interrupts and how to implement them on the T3.2 evades me..
Thank you in advance.
Here's what I've put together so far:
Code:
#define ENCODER_OPTIMIZE_INTERRUPTS
#include <Encoder.h>
Encoder Enc(15, 16);
void setup()
{
pinMode(15, INPUT_PULLUP);
pinMode(16, INPUT_PULLUP);
attachInterrupt(15, endoce, CHANGE);
attachInterrupt(16, endoce, CHANGE);
Serial.println("Encoder Test:");
}
volatile long Pos; volatile int count;
void loop()
{
}
void endoce()
{
noInterrupts();
Pos = Enc.read();
if (Pos != count)
{
Serial.print("Pixel# = ");
Serial.println(Pos);
count = Pos;
}
interrupts();
}