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!
Ad Blocking Detected
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).
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)
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).
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.
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).
TinyMediaManager Small, but slick little application to manage your movies and movies meta-data (Windows, MacOS X and Linux!).
PDFCreator Ultimate tool for Windows users: Print ANYTHING you can print to a PDF with this FREE printer driver.
ForkLift Great tool for FTP, SFTP, remote editing of text files (through SSH) and even a great Finder replacement - Not free, but keep an eye on special offerings (I got my copy for $5)
Put.io Online disk ruimte met Torrent mogelijkheden!
GTMetrix Awesome tool to analyze the speed of your website!
Microsoft PowerToys for Windows 10 Back in the day (Windows 98/XP era) we had PowerToys - Microsoft released them again for Windows 10 (free)
Links Page These and more of our favorite links can be found on the Links Page.
New Downloads
ConnectMeNow4-v4.0.9-macOS-arm64.dmgDate: 2023-05-28 - Size: 2.6 MBVersion 4 of ConnectMeNow - A tool for more convenient mounting of network shares under macOS. This is the Apple Silicon version (not suitable for Intel).
ConnectMeNow4-v4.0.9-macOS-x86-64.dmgDate: 2023-05-28 - Size: 3 MBVersion 4 of ConnectMeNow - A tool for more convenient mounting of network shares under macOS. This is the Intel version which works on Intel and Apple Silicon Macs.
MovieScanner2-2.2.3-Windows-32bit-setup.exeDate: 2023-04-12 - Size: 18.6 MBA small application that uses FFProbe to scan your video files and logs these details in a small database. This is the 32 bit Windows version.
MovieScanner2-2.2.2-Linux-GTK-64bits.tar.gzDate: 2023-04-11 - Size: 29.2 MBA small application that uses FFProbe to scan your video files and logs these details in a small database. This is the 64 bit Linux version for GTK.
MovieScanner2-2.2.2-Linux-QT5-64bits.tar.gzDate: 2023-04-11 - Size: 29.1 MBA small application that uses FFProbe to scan your video files and logs these details in a small database. This is the 64 bit Linux version for QT5.
MovieScanner2-2.2.2-macOS-x86-64.dmgDate: 2023-04-11 - Size: 26.3 MBA small application that uses FFProbe to scan your video files and logs these details in a small database. This is the 64 bit macOS version.
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).