Hello. I've hooked to a rotary encoder to my Arduino Pro micro. (Basically a mini unofficial duemilanove).
The weird thing is that the SW pin (which is connected to the push button of the rotary encoder) changes state whenever I rotate the encoder knob! More precisely it goes to 0 in the mid position between two detents of the knob (I know this because I printed the digitalRead value of the switch pin to the serial port)
I couldn't find any lose connection or shorts. The board is powered via USB. There are no capacitors used for damping. The wires if the encoder are connected directly to the Arduino
Hello
Check the wiring again and make cross checks.
Post your current sketch, well formated, with comments and in so called code tags "</>" and a schematic, not a Fritzy diagram, to see how we can help.
Have a nice day and enjoy coding in C++.
Дайте миру шанс
So I found the problem.
I was using a digital out pin to power the encoder. (Because my board has only one V out which is already used). I simply made that pin out put a HIGH voltage in the hopes that I would act as a V out .
However, this caused the Problem that I have described above.
But the problem settled when I set that pin to OUTPUT pin mode.
Maybe I should have tried this earlier.
That is because without setting the pin to OUTPUT mode, you were powering the encoder through the internal pullup resistor, creating a voltage divider with the pullup resistors of the encoder. Likely when both encoder contacts were closed the voltage was low enough to read as a LOW on the open switch contact.