Rotary Switch Colour Selector help needed

retrolefty:
Not saying a rotary encoder wouldn't work and might very well even be a more elegant and resource saving solution, but to say a simple 7 input pin polling sketch is other then a very simple task is assuming more requirements then the OP stated. Recall that the OP stated that he already has the switch in hand. I would think it's a very good method for a beginner first learning programming and hardware electronics, rather then relying on a library based solution.

Well from a programming stand point, I think a seven level deep block of nested if-then-else statements evaluating if each pin is TRUE would be fairly simple. However, it would take up quite a few lines by itself and be somewhat cumbersome if you ever had to debug it. :wink: Furthermore it's perhaps the most compact ways to express the logic without getting into rather arcane tricks.

Yet, you are correct that using the available hardware is probably the best approach for this particular device since it's definately a workable solution. Still it doesn't hurt to bring up the alternatives, even if they aren't used. There's always the next project... :slight_smile: