# Funky switch

<figure><img src="https://1937097571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXsx2Pyx5QBO3iWZFpmmR%2Fuploads%2FOGy7AhQKuPQ2YaMtyCa5%2Fimage.png?alt=media&#x26;token=08d8c201-f87e-41dc-a813-52d3e387f9ab" alt=""><figcaption></figcaption></figure>

Alps RKJXT1F42001, or just "funky switch". It has an encoder, covered under [funkyRotary](encoders/funkyrotary), 4 directional button presses and 1 center pushbutton.

<figure><img src="https://1937097571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXsx2Pyx5QBO3iWZFpmmR%2Fuploads%2FAurijlkrRC1ZFrzZtraI%2Fimage.png?alt=media&#x26;token=6cbc0291-137a-4098-be30-c7e4724701b8" alt=""><figcaption></figcaption></figure>

As you can see from the schematic above, no directional input (A,B,C,D) will find its way to common pin unless pushbutton also i pressed. This is how this switch works. The pushbutton is pressed together with every directional input. It serves as a pushbutton, but is also designed to prevent bouncing, by only closing the circuit to common when the switch is properly in place. This gives us a problem to solve however, since you can't tell if the center push button is pressed alone by only reading the value from that button. We'll need an algorithm that avoids producing a button press if the pushbutton is pressed together with a directional button press. That is why funky switches have their own pushbutton functions.&#x20;

There are different algorithms for the center push button and the directional buttons, so they are listed seperately. _**You'll need to use one function for each directional input, and one for the push. Five altogether.**_&#x20;

When setting up a funky switch in 30\_Switches.ino, you should list the directinonal functions first, and the center push button function last:

<figure><img src="https://1937097571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXsx2Pyx5QBO3iWZFpmmR%2Fuploads%2FvjUkVZZ1HOaYVsrdqql4%2Fimage.png?alt=media&#x26;token=bb379185-6cb4-4b28-ba4a-3ecc0a3845d3" alt=""><figcaption><p><mark style="color:green;"><strong>Correct</strong></mark></p></figcaption></figure>

<figure><img src="https://1937097571-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FXsx2Pyx5QBO3iWZFpmmR%2Fuploads%2FbLj0yUOrvGw2WE9Px2VC%2Fimage.png?alt=media&#x26;token=dbafd35f-ed35-4032-9c16-964ea3ac4ec6" alt=""><figcaption><p><mark style="color:red;"><strong>Incorrect</strong></mark></p></figcaption></figure>
