Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting rotary encoders working with an Arduino Uno #1

Open
utterances-bot opened this issue Jul 10, 2018 · 3 comments
Open

Getting rotary encoders working with an Arduino Uno #1

utterances-bot opened this issue Jul 10, 2018 · 3 comments

Comments

@utterances-bot
Copy link

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

Copy link

xrisk commented Jun 2, 2019

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.

@eeeeeta
Copy link
Owner

eeeeeta commented Jun 8, 2019

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 :)

Copy link

kesor commented Apr 6, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants