¿ªÔÆÌåÓý

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

Increment Problems [1 Attachment]


Gary White
 

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.h>

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");
}
}


Dennis Stage
 

¿ªÔÆÌåÓý

Voltage on the + connection of the KY 040 measures 5.07vdc
?

To: SoftwareControlledHamRadio@...
From: SoftwareControlledHamRadio@...
Date: Tue, 5 Apr 2016 18:22:53 -0500
Subject: RE: [SoftwareControlledHamRadio] Re: Increment Problems [1 Attachment]

?
[Attachment(s) from Gary White included below] Dennis,

Does your encoder have a small printed circuit board like this? These are the common KY-040 encoder. You may also have the encoder without the pcb. If you have this type, run a line from 5 Vdc on the DDS VFO board (pick it off J1) to the pin marked plus (+) on the pcb. This line is not shown on the DDS VFO schematic.?

These types of encoders seem to conflict with the internal pull down circuit in the Nano and prevent incrementing or decrementing frequency unless you supply them with a 5 Vdc source. I have not tried using a bare bones encoder (one without the pcbs) but I have a few in my junk box and might try one later tonight.

73

Gary W5GW


?