Welcome to the Tweaking4All community forums!
When participating, please keep theĀ Forum RulesĀ in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For exampleĀ “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post willĀ not bring you to the same post, in Dutch, as there is no translation for that post!
It's been a very long time that I played with a rotary switch, but I think the biggest, and I've never used the Rotary library (I've found a few, but I'm assuming it is this rotary lib?), so I'm not sure what I'm even looking at.
Pins 2 and 3 seem a good choice since most common Arduino's support these 2 pins for attaching an interrupt to.
When looking at this example code for rotary.h; I see no purpose of A0?
/*
Rotary Encoder - Interrupt Example
The circuit:
* encoder pin A to Arduino pin 2
* encoder pin B to Arduino pin 3
* encoder ground pin to ground (GND)
*/
#include <Rotary.h>
Rotary r = Rotary(2, 3);
void setup() {
Serial.begin(9600);
r.begin();
PCICR |= (1 << PCIE2);
PCMSK2 |= (1 << PCINT18) | (1 << PCINT19);
sei();
}
void loop() {
}
ISR(PCINT2_vect) {
unsigned char result = r.process();
if (result == DIR_NONE) {
// do nothing
}
else if (result == DIR_CW) {
Serial.println("ClockWise");
}
else if (result == DIR_CCW) {
Serial.println("CounterClockWise");
}
}
With limited info and zero experience with the rotary library, I can only throw out some random thoughts.
From the rotary lib documentation, I assumed the rotary lib would already handle the interrupts. I could be very wrong though.
Next, you say it works on an Arduino Uno (assuming this is what you mean with Arduino 1???) but not on the mega it does not. Does the rotary example code for interrupts work?Ā (the one I just posted - copied from the rotary library documentation)
Oh cool! Good to know 👍🏻 Also thank you for posting the hint where to look -- others will benefit from it I'm sure.
Just being curious though; did you run the test on the Uno and the Mega? And both worked? Just wondering if the additional "A0" causes and unexpected problem on the Mega - It's not part of the rotary, right?
The call to the Rotary function accepts 3 arguments, the first two being the interrupt pins coming from the encoder and the third the pressed button present in the mechanical encoder.
AlternativeTo Great resource when you're looking for alternatives for an application that you'd like to use, but might not be available on your platform or the application you have is just not doing it right.
HandBrake Great tool for ripping DVD's and converting video.
XMedia Recode Excellent tool for Windows users to convert pretty much any video format to any other video format, including some helpful options like removing unwanted tracks.
PDFCreator Ultimate tool for Windows users: Print ANYTHING you can print to a PDF with this FREE printer driver.
IINA VideoPlayer One of the best media players for MacOS X - it's free and a great alternative for, and more stable than, VLC.
XSlimmer Awesome tool to get back some of the wasted harddisk space by removing unused application stuff. Highly recommended!
Links Page These and more of our favorite links can be found on the Links Page.
New Downloads
ConnectMeNow4-v4.0.19-beta-macOS-Universal.dmgDate: 2026-03-08 - Size: 5.7 MBVersion 4 of ConnectMeNow Beta Releasse - A tool for more convenient mounting of network shares under macOS. This is the Apple Silicon version (not suitable for Intel).
squirclenomore-v1.0.3-macos.dmgDate: 2026-01-20 - Size: 5.5 MBmacOS Tahoe applies a very ugly Squircle jail to application icons - SquircleNoMore removes these and resets the normal application icon.
RenameMyTVSeries-2.3.15-Windows-x64-setup.exeDate: 2025-12-14 - Size: 49.1 MBRename My TV Series, for Windows (Intel 64 bit), a tool to assist in renaming TV Show episode files. Static builds of ffmpeg and ffprobe are included.
RenameMyTVSeries-2.3.12-GTK-Linux-x64-static-ffmpeg.tar.xzDate: 2025-10-06 - Size: 78.3 MBRename My TV Series, for Linux (64 bit GTK), a tool to assist in renaming TV Show episode files. This bundle comes with (large) static builds of ffmpeg and ffprobe.
RenameMyTVSeries-2.3.12-QT5-Linux-x64-static-ffmpeg.tar.xzDate: 2025-09-28 - Size: 78.3 MBRename My TV Series, for Linux (64 bit QT5), a tool to assist in renaming TV Show episode files. This bundle comews with rather large static builds of ffmpeg and ffprobe.
Downloads Page Find these and more Downloads on the Downloads Page, where you will also find articles references, operating system requirements and categories.
Amazon Ads
Support us by doing your shopping at Amazon.com, either click the link, or click one of the links below …
You can also sponsor us through theseĀ Amazon offerings:
Please consider disabling your ad blocker for our website.We rely on these ads to be able to run our website.You can of course support us in other ways (see Support Us on the left).