October 3, 2010

Arduino Pushbuttons The Easy Way

Here's a schematic on a stripboard of a simple pushbutton (with a pull-down resistor) to be used with Arduino:


And here's how more pushbuttons can be chained together:


Here's an implementation of a pushbutton on a stripboard:


and here's a couple of pushbuttons connected together:


Here is an example of a sketch using such a pushbutton to toggle on and off a LED (this example has been derived from the one described in Arduino Playground, using a software debounce approach, extended to play an action once per button press):

example_PushButtonWithDebounce_v1.pde
(compiled with Arduino IDE 0022)

UPDATED: another way to do exactly the same with less components, is to enable the internal pull-up resistor of the digital pins.

This way, the schematic on a stripboard of a simple pushbutton (without any pull-up/down resistor) is the following one:



And here's how more pushbuttons can be chained together:



Here is an example of a sketch using such a pushbutton to toggle on and off a LED (this example has been derived from the one described in Arduino Playground, using a software debounce approach, extended to play an action once per button press):

example_PushButtonWithDebounce_v2.pde
(compiled with Arduino IDE 0022)