INTRODUCING BUTTONS

It’s now time to add a new component to our circuit – a pushbutton (or just “button”).  A button is just a very simple switch – when it’s not pressed, electric current can't flow through the button and when it is pressed, electric current does flow through the button.

Let’s take a closer look at how a button works.  This is a representation of most basic pushbuttons – they have four “legs” that can be attached to your breadboard and wired to the circuit and then one button in the center of the device that can be un-pushed (“open”) or pushed (“closed”):

Internally, the left side of the button (the two legs on the left) are connected together, and the right side of the button (the two legs on the right) are connected together.  The left side and the right side are separated by a switch that opens and closes as the button is pressed or unpressed:

When we insert a button into a circuit, it has one of two operations:

  1. When the button is left unpressed, it creates an open circuit, no electric current can flow through the button and nothing happens.

  2. When the button is pressed, the button acts as a wire and closes the circuit – electric current can then flow through the button.

So, if we go back to our first breadboard circuit containing a simple resistor and LED that is always illuminated, we should be able to add a switch that we can then use to control the LED turning on and off (by pressing the button).

Let’s build that circuit now…

Here’s what the schematic will look like:

To build the circuit, we can start with the circuit we built in Raspberry Pi Power:

Step #1:  Remove wire from LED to ground.

We’re going to be adding the button into the circuit between the LED and ground, so the first step will be to remove the wire that connects the LED to ground. 

This is what the breadboard should look like at this point:

Step #2:  Provide connectivity from the LED to the button.

The next step is to provide connectivity between the second lead of the LED and the button.  While we could wire the button in the same connect row as the LED to provide this connectivity, the buttons take up a good bit of space in a connect row, and it would be hard to fit the LED, the button and the wires we'll need all in the same row.  For that reason, we suggest running a wire (the half-inch green wires work great for this) from the connect strip that the LED is in to a new connect strip that we can use for the button.

Assuming you choose to do it this way, this is what the breadboard should look like at this point:


Step #3:  Place button on the breadboard.

Next, we’ll place the button on the breadboard.  Note that the button should be oriented so that the two sides of the button sit on different connect strips, as follows: 


CORRECT WRONG!!!


One side of the button should sit in the same connect row as the green wire from the LED.  This will provide connectivity from the LED through the green wire and to the button, as follows:

Note:  In our diagram above, you'll notice that the button sits across a notch in the breadboard.  This isn't absolutely necessary -- the button could sit with both left legs in the same connect strip and both right legs in the same connect strip.  But, because buttons take up a lot of space on the breadboard, we find it easier to position them across a notch in many cases.  You can decide how you want to wire your buttons, but keep in mind that either way will work.

Step #4:  Connect the other side of the button to ground.

Finally, we can complete the circuit by connecting the other side of the button to ground, like this:

At this point, your LED should not be lit.  Remember, while we have a potentially complete circuit, there is still a lack of physical connection through the button until the button is pressed.  In other words, there is a break in the circuit inside the button (this is how a button works) and the way to complete the circuit is to press the button.

If you press the button, you should see the LED illuminate.

"Breaking the Circuit"
In this project, we controlled the flow of electric current through the circuit by inserting a switch (the button) between the LED and ground. That said, the switch didn't need to be inserted at that point in the circuit for it to work -- we could have inserted the switch anywhere in the circuit and it would have worked the exact same way. Remember, if the flow of electric charge is broken anywhere in the circuit, the circuit will fail to operate. So, our decision to insert the button where we did was completely arbitrary.

In this project, we’ve manipulated the circuit using a purely physical device.  By inserting the button into the circuit, we can interrupt the flow of electric current through the button (and therefore the circuit) by not pressing the button and then restore the flow of electric current through the button (and the circuit) by pressing the button. 

Congratulations!  You’ve just built the same circuit used in most simple flashlights…

In the next project, we’ll add software into the equation using GPIOs.

prev| next