2 and 3 way selector switches

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.