Closed javest closed 6 years ago
There's no reason why it should't work. Both INT0 and INT1 are working just fine; just tested it on my STK500 dev board.
Does this example code toggle PB0 when INT0 or INT1 changes state?
volatile int lastEncoded = 0;
volatile int direction = 0; // 1 = senso orario 0 = senso antiorario
volatile int clock = 0; //manda un incremento come fronte di salita
const int encPinA = 10;
const int encPinB = 11;
const int led = 0;
void setup()
{
pinMode(encPinA, INPUT);
pinMode(encPinB, INPUT);
digitalWrite(encPinA, HIGH);
digitalWrite(encPinB,HIGH);
pinMode(led, OUTPUT);
attachInterrupt(digitalPinToInterrupt(encPinA),decodeEncoder,CHANGE);
attachInterrupt(digitalPinToInterrupt(encPinB),decodeEncoder,CHANGE);
}
void loop()
{
}
void decodeEncoder()
{
PORTB ^= _BV(PB0);
}
I'm trying to use interrupts on atmega8515
i'm trying to decode a quadrature decoder using two input pins with interrupts. The funcion"decodeEndoder()" works on attiny85. It is the correct way to attach interrupts? It seems that digitalread inside ISR routine doesn't give us the right value.
This is our code. Do you have any example of using interrupts whit your library?