Hi, silly question first, did you test the pins of the switch you are using with a voltmeter to be sure is working correctly?
Then, if what you're using is a rotary encoder I suggest you to read this:
http://www.circuitsathome.com/mcu/reading-rotary-encoder-on-arduino
From your description however it seems more a 5 state switch, and in that case I would do something like this:
//initialize a variable "state"
int state;
//create a function that reads continously the pins
//and returns the pin number
int rotaryEncoderCheck() {
//from pin2 to pin6
for (int i=2; i<=6; i++) {
//if the pin is HIGH
if(digitalRead(i) == HIGH) {
//return its value
return i;
}
}
}
//put in your loop this call to the function
//and with state value control the logic
state = rotaryEncoderCheck();
Bye! ![]()