¿ªÔÆÌåÓý

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

Re: Increment Problems


Dennis Stage
 

¿ªÔÆÌåÓý

Just got back. Been at my mountain property trying to get a cabin built.? Will all that you suggest later today.

Thanks for the input.


To: SoftwareControlledHamRadio@...
From: SoftwareControlledHamRadio@...
Date: Tue, 5 Apr 2016 20:22:04 -0500
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.