I purchased a cheap eBay sensor kit just to mess around with and learn how different sensors work. (I don't recommend buying one. The sensors I have messed with so far all seem to be only slightly better than garbage. "You get what you pay for" comes to mind.) This kit included a Rotary Encoder Module (pics below).
The rotary encoder part of this module seems to work as it's meant to. However, the knob doubles as a switch (push button). Now comes the trouble.
This module is connected to the Arduino's 5v and GND. And SW, DT and CLK to pins 3, 4 and 5 (respectively).
I edited my code down to the simplest I could for testing the issue.
int buttonPin = 3;
void setup() {
Serial.begin(9600);
pinMode(buttonPin, INPUT);
}
void loop() {
int buttonRead = digitalRead(buttonPin);
if (buttonRead == HIGH) {
Serial.println("Button Was Pressed");
} else {
Serial.println("Button Idle");
}
delay(20);
}
Now, what it is printing is
Button Idle
Button Idle
Button Was Pressed
Button Was Pressed
Button Idle
Button Idle
Button Idle
Button Was Pressed
Button Was Pressed
Button Idle
Button Idle
Button Idle
Button Was Pressed
Button Was Pressed
Button Idle
Button Idle
Button Idle
Button Was Pressed
Button Idle
Button Idle
Button Idle
Button Was Pressed
Button Was Pressed
Button Idle
This is without any interaction with the button.
So, bad module?? I won't be surprised if it is.
images




Nevermind!
I went through the whole taking pics and making a post for nothing.
Seems the module was sitting on a surface that I "thought" didn't conduct. Turns out it does to some extent. I just placed it on a piece of foam to keep it from moving around as much and it works fine.
Time to find a better work surface. I see now why a lot of folks use one of those cutting mats!
The pin must be floating. I'm making an educated guess that the missing R1 on the back of the module was supposed to be the pull-up.
pinMode(buttonPin, INPUT_PULLUP);
Ok, I see you may have solved it. I'm still not convinced though...
arduarn:
The pin must be floating. I'm making an educated guess that the missing R1 on the back of the module was supposed to be the pull-up.
pinMode(buttonPin, INPUT_PULLUP);
Ok, I see you may have solved it. I'm still not convinced though...
Good eye!!
Made me go get my glasses and have a real look at the thing. And then it hit me that I could see the image above a whole lot easier! LOL.
Thanks! I'll make that change.
Hi,
A schematic would help at this point, just a picture of a hand drawn circuit would be great?
Thanks.. Tom.. 
TomGeorge:
Hi,
A schematic would help at this point, just a picture of a hand drawn circuit would be great?
Thanks.. Tom.. 
A schematic will show this:
This module is connected to the Arduino's 5v and GND. And SW, DT and CLK to pins 3, 4 and 5 (respectively).
It's the chip, the Arduino and 5 connecting wires. Nothing more. It's a cheap Chinese board without any name. Closest I can find is shown at this address:
Are those resistors, R2 & R3, soldered on both ends?