- Discrete LEDs
- Dot/Bar LEDs
- Matrix LEDs
- 7-Seg LEDs
- Serial -- Software
- Serial -- Hardware
- RS-232 via the MAX3232
- I2C -- EEPROM
- I2C -- DS1307 Real Time Clock
- 1-Wire -- DS18B20, Powered, Single-Drop
- 1-Wire -- DS18B20, Powered, Multi-Drop
- 1-Wire -- DS18B20, Parasitic, Multi-Drop
- TI Link Protocol -- Calculator Demo
- Infrared Communication
- MIDI -- Output Demo
- MIDI -- Input Demo
- MIDI to Analog Synth
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