Propwash dual encoder question

How does the switch part of the encoder work? I found this on youtube.

So there is a GND for the switch part. I think maybe, I need to connect the other switch terminal to an Analog Input pin. So does it work this way: GND pulls the other terminal LOW and when the switch is pressed, the other terminal goes HIGH?

Thanks,
Chris

The switch is simply that, a switch that connects the two contacts when pressed and isolates them when released.

How you wire the contacts will determine the “logic” of the switch. Most applications that I have seen wire one side of the switch to ground and the other side to both a suitable pullup resistor and a digital input pin and this is how I’ve wired mine. This will pull the pin from logic high to low when the switch is pressed.

Arduinos (and probably most other microcontrollers) have inbuilt, switchable pull up resistors on all input pins (negating the need for discrete pullup resistors in the circuit) so the best way to sense the input is to look for the pin being pulled low by the switch contacts making when pressed.

Thanks a lot for the clarification. Hey just an FYI, I managed to put together an arduino button class which so far seems to have excellent software switch debouncing.

class Button {
  public:
uint8_t gpioSw;
uint16_t btndbc = 0, lastb = 0;
    
Button(uint8_t ipin) : gpioSw(ipin) {
   pinMode(gpioSw, INPUT_PULLUP);
}

//Based on https://www.best-microcontroller-projects.com/easy_switch_debounce.html
bool check(){
   btndbc=(btndbc<<1) | digitalRead(gpioSw) | 0xe000;
   //if (btndbc!=lastb) Serial.println(btndbc,HEX);
   lastb = btndbc;
   if (btndbc==0xf000) 
     return true;
   return false;
}
};

Chris