Hey folks,
I have an encoder in form of a hall sensor. It works when I use the Interrupt pins 18,19 on the mega. Using quadrature I get the speed of the motor. But when I attachInterrupt(digitalPinToInterrupt(interruptPin), blink, CHANGE); with pins 2,3,20,or 21 instead of 18,19 nothing works anymore. Any clues? Do I have to treat those pins differently?
your right sorry about the missing code. The isr gets called on pin 20 and 21. So nothing wrong with interrupt. But my routine is doing something wrong, I use the following for the encoder:
okay I got it to work. 20 and 21 is on Port D so the line will change to ((PIND & 0b0011));
as it is the 3rd and 4th bit of the PortD read byte. And then the shift of 2 is not needed anymore.