Three-Position Switch


In this exercise we see how to read a three position switch, but only using two port pins. The secret is that the toggle switch is a center-off type. Noting the fact we're employing the usual pull-up resistors on the two port pins, the binary numbers 10, 11 and 01 are sensed on the pins and appropriate action is taken. In this case it means lighting one of three LEDs.


There's nothing too boggling in the source coded, but you might want to note the use of the Pascal CASE statement which is surely a handy structure.

Click to get the source code.
Click to get the schematic PDF.

Next Project: Digital Joystick

No comments:

Post a Comment