Most buttons come in two varieties, NO, and NC.

NO: Normally opened. When you press the button, the circuit is closed. These are more commonly found.
NC: Normally closed. When you press the button, the circuit is opened.

Basic button circuits

Most button circuits will require some connection to a high voltage, low voltage, the signal detector (usually an input pin on a microcontroller), and a resistor. The resistor will either be called a pull-up resistor, if it is connected to the high voltage, or a pull-down resistor, if it is connected to the low voltage. If there is no resistor, when the button is closed it will short the high to low. Most microcontrollers have either a pull-up or pull-down resistor built into their input pins. This means you just need to connect the button to the input pin and either the high or low voltage (the opposite of the built in resistor).


Buttons have a tendency to "bounce", or rapidly open and close when they are pressed or released. This could create false signals in your microcontroller program, making it think the button was pressed and released multiple times (when it really only happened once). In order to prevent this, you must put "debounce" into your design. This can be handled is hardware or software. Hardware is usually much easier.

Hardware debounce

Put a small capacitor in parallel with the button. Because capacitors can't change voltage instantaneously, it will prevent bouncing on your button's voltage. While simple, this adds an extra component to the circuit, and will lower the response time ever so slightly of the button. However, in most cases, it is still sufficiently fast.

Software debounce

The button should be ignored for some time period after each press/release. This can be accomplished by either putting in a delay whenever a transition is detected, or design your button check code to ignore the button, if the specified period of time has not elapsed after a button press/release. This will mean only the first transition in a press/release event is detected. If you have a program that is not time critical, the first solution is easier. However, this can have a serious detrimental effect on your program functioning properly, especially if the delay is put in an interrupt routine. The second is slightly more complicated to program, but prevents ugly and unnecessary delays.