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

No comments:

Post a Comment