arduino icon indicating copy to clipboard operation
arduino copied to clipboard

polling works, but not interrupts

Open thijsdeschildre opened this issue 5 years ago • 3 comments

I can't get this to work with interrupts on an Arduino Nano (and Attiny85 ultimately). Software polling works.

Starting with the example cocde, I defined the rotary encoder with pins 8 and 9, and attached interrupts 0 and 1 to the rotate subroutine. With software polling I measure a pullup on the rotary encoder, but not when using the interrupts. I added a pullup with a 2K resistor to 5V, which doesn't help.

thijsdeschildre avatar Sep 03 '20 10:09 thijsdeschildre

Did you declare your variables (used in the ISR) to be volatile?

KarateBrot avatar Sep 03 '20 16:09 KarateBrot

Did you declare your variables (used in the ISR) to be volatile?

No, I just used the interrupt example as it is. Only changed the pin numbers. With my extra code, later on, this would be necessary alright.

thijsdeschildre avatar Sep 03 '20 18:09 thijsdeschildre

Use the same pins you declared Rotary on for attaching the interrupts, worked for me

elijahshumway avatar Dec 30 '21 20:12 elijahshumway