¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: Increment Problems


 

FWIW: you shouldn't use a Serial.print() call in an ISR, since that method uses interrupts itself. Something is definitely out of whack here, since there are over a hundred of these boards out there being used with the software. I'm starting to think there's a bad component somewhere in the chain.

Jack, W8TEE



From: "Gary White white512@... [SoftwareControlledHamRadio]"
To: SoftwareControlledHamRadio@...
Sent: Tuesday, April 5, 2016 9:22 PM
Subject: RE: [SoftwareControlledHamRadio] Re: Increment Problems

?
Dennis,

Well I¡¯m stumped then. Bye the way, I hooked up a bare encoder without the external pull-up resistors (that is what is on the pcb) and it worked fine.

Can you load the example called ¡®INTERRUPT¡¯ that came with the library. Pull the Nano off the DDS VFO. Run the encoder to pins 2, 3, and ground (no 5 Vdc needed). Open the serial monitor (make sure it is at 9600 baud) as you turn the encoder it should print out CW or CCW.

Here is the code for it:

/*
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 r = Rotary(2, 3);

void setup() {
Serial.begin(9600);
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");
}
}


Join [email protected] to automatically receive all group messages.