I’ve had a lot of fun working with electronics recently. With my background as a programmer, I’m very comfortable writing the code for these projects but I’ve certainly got a long way to go with the hardware. In this post I’d like to show you how to wire a pushbutton in a very simple circuit.
Pushbuttons come in different shapes and sizes and will be internally wired in one of two ways:
- Normally Open (NO) – The circuit will close (electric current will flow) when the button is pushed and it is otherwise open.
- Normally Closed (NC) – The circuit will open (electric current will cease to flow) when the button is pushed and it is otherwise closed.
The most common of these is the NO variant where electric current flows when the button is pushed. Note that some buttons will provide both options with one pin for each option. In this post we will be using a NO button.
The pushbutton we will be working with is the Red Massive Arcade Button with LED from Adafruit. This button has an optional LED that will light up the button. The LED has a built-in resistor so you can run it up to 12V.
The button has four pins.
The two pins on the sides are the power and ground pins for the LED.
The bottom pin is labelled COM which is for common. This should always be connected to power.
The middle pin is the NO pin and is labelled as such. As long as you have connected your COM pin to power, this pin will output electric current when the button is pushed. The electric current will then be flowing from your power source through the pushed button and out of the NO pin. As soon as you release the button, the circuit will open and electric current will cease to flow through it.
Let’s have a look at a sketch that demonstrates this functionality.
In the sketch below, we use an Arduino Uno as our power supply. The yellow wire connects the COM pin to power and the green wire connects the NO pin to the LED on the breadboard. In this example the red LED will light as long as the button is pushed.
Note that we are not connecting the built-in LED of the pushbutton in this example.
We now have a functioning pushbutton and that concludes this tutorial.
In the next post we’ll look at how to program the button so that a single push of the button will be enough to either change the circuit state permanently or fire a sequence of actions before returning to it’s original state.
I Hope this has been useful. Feel free to leave a comment or find me on Twitter.