- Discrete LEDs
- Dot/Bar LEDs
- Matrix LEDs
- 7-Seg LEDs
- LCDs
- Switches
- KBDs
- Sensors
- Motors
- Analog
-
Comm
- 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
- Miscellaneous
Pushbutton Switch
The time has come to learn about PIC input. Let's begin with a simple pushbutton switch. We'll give it toggle action: press once, the LED lights and stays lit. Press again, it goes off and stays off. The wiring and the PMP code couldn't be simpler.
Pushbutton switches are notorious for contact bounce, especially the likes of the cheap one you see in the photo above. So, we'll let the code work in some simple software debouncing. Here I've simply used a time-based scheme, rather than a more complex flip-flop type arrangement. But it works just fine for most applications.
Click to get the source code.
Click to get the schematic PDF.
Next Project: Three-Position Switch with Two Wires
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment