2 and 3 way selector switches

Hi,

Can someone tell me how to code one and two way rotary switches?

For the 3 way rotary switch: Left Pos = press 'KEY_LEFT_ARROW' Middle = Do nothing. Right Pos = press 'KEY_RIGHT_ARROW'

For the 2 way rotary switch Right pos = press 1 Left Pos = press 2

Anybody know how to do this? I do not know how to have it only register once instead of it constantly pressing the keyboard key.

Thanks

The StateChangeDetection example in the IDE (under examples / digital) would be a useful resource.

Hi I have read it...

I still do not understand.

Somebody told me to do this but I do not know if it will work:

if (selectorHX != selectorPOS){
  delay (100);}
  if (selectorPOS == LOW){ // If switch is in the 'one' position
    Keyboard.press(KEY_LEFT_ARROW);
    delay (100);
    Keyboard.releaseAll();
    selectorHX = selectorPOS;}
  else{
    Keyboard.press(KEY_RIGHT_ARROW); // If switch is in the 'two' position
    delay (100);
    Keyboard.releaseAll();
    selectorHX = selectorPOS;}

That is only a snippet of code, so my snippet of an answer is: It.

In any case, it would be faster to try it on an Arduino than to post on this forum and wait for an answer.