Open utterances-bot opened 6 years ago
No, I don't believe using ISRs would break serial, as it doesn't use any interrupts to begin with. In fact, you can use serial with interrupts completely disabled.
Hey @xrisk, thanks for the comment! I think you probably are right about that - it was a while ago, and I couldn't remember whether it broke serial or not, but what you've said sounds right to me! I've added a small note on the article next to that bit to point it out for future readers :)
Excellent article! But as you said, you have a problem where the PCB is already using "non-interrupt" pins. Well, here is some good news for you - While the D2 & D3 pins are "external interrupt" pins and can detect FALLING/RISING edges. It turns out that ALL THE PINS on the Arduino are also interrupt capable and can trigger an interrupt for any CHANGE.
The only caveat, is that Arduino pins are arranged into 3 ports (8 bits each), PORTB, PORTC and PORTD. If you are using the "pin-change" interrupts, the interrupt routine will trigger on any of the pins for that port. So you can have an interrupt routine for PORTD for example, and it will get executed when any of the pins on PORTD is changed.
There is more information about this in the Atmega328 datasheet, and if you look at the pinout diagrams all the pins have a "PCINTxx" number next to them - that is the "pin change interrupt" number of these pins.
Getting rotary encoders working with an Arduino Uno
I’ve been doing a bunch of stuff with an Arduino Unorecently. In particular, one of those things is trying to get anincremental rotary encoder(in my case, an...
https://theta.eu.org/2018/03/31/arduino-rotary-encoders.html