Roraty encoder with push button

I have rotary encoder with 5 pins. One is SW and I understan that this should be linked to the momentary push button (the shaft can be pushhed down).
Unfortuantely when I connect the rotary encoder and connect SW to Arduino pin I see no signal change at that pin when I push the shaft.
Is it possible that the encoder is sold without the push button functionality?
all I am doing is connecting SW to digital pin 2
and in the code I do pinMode (2, INPUT);
and in loop
Serial.println(digitalRead(2);

And I get 0 all the time and I would expect 1's when it is not pushed and zero when it is

set the pin to INPUT_PULLUP

EDIT: and GND obviously :slight_smile:

Thank you:). Trying it now

You've only mentioned connecting one pin on the encoder.
This may be stating the obvious but ...

For the 5 pin rotary encoders I have, there are 3 pins on one side for the rotary function and on the other side of the package there are 2 for the push switch. The pins on each side are electrically independent. If you want to use the push button you have to connect one of the pair to an input pin and the other adjacent pin to to ground, assuming you're using the internal pull up resistor.

Silly me. I should have guessed it myself:)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.