INTRODUCING BUTTONS
In this project, we're going to introduce an input device -- the pushbutton -- that will allow us to start controlling the functionality of our circuit.
Hardware setup from previous project
I/O (Input/Output) RaspberrySTEM Cell
Having issues? Check out the Troubleshooting Guide.
Learning About Circuit Input/Output

Now that we've built our first circuit on the breadboard and have it being powered by the Raspberry Pi, it's time to start controlling that circuit. We do this through mechanisms called "input" and "output". the input and output of a circuit.

Input is information we receive from the outside world that gives us an idea of what our circuit should do next. For example, when you press a button on a TV remote control, it tells your television to do something (change the channel, increase the volume, etc). The remote control is called an "input device." There are lots of different types of input devices that circuits can use, and button input is one of the most common. the input and output of a circuit.

Output is information that your circuit provides back to you. Output comes in many different forms, and common forms of output are things that can be picked up by your senses -- for example, lights and displays that you can see or buzzers that you can hear. But, output can also be in the form of motors/movement (for example, a robot or a remote controlled car) or in the form that you can't detect without specialized equipment (infra-red light, for example). the input and output of a circuit.

Any interesting circuit is going to take input and provide output, and the circuits we'll be building with the RaspberrySTEM CREATOR Kit are no different. Over the next several projects, we're going to work with two very common forms of input and output -- we'll be using pushbuttons for input and our LEDs for output. the input and output of a circuit.

Each of the next several projects will provide more complex and interesting ways in which we can control circuits with input and output. Here is what we plan to do: the input and output of a circuit.

  1. In this project (Project #5), we will add a pushbutton input to the circuit that we've already assembled on our breadboard. The circuit input (the pushbutton) and output (the LED) will work strictly using hardware -- there will be no software involved in the control of the circuit.

  2. In Project #6, we'll learn how to use software to control our output device (LED).

  3. Then, in Project #7, we'll learn how to get input from our input device (pushbutton) to our software.

  4. Finally, in Project #8, we'll put it all together and use the pushbutton input into our software to control the LED output.

In other words, over the next three projects, we will go from using getting input and displaying output strictly through hardware to using software to monitor and control the input and output of a circuit.

As we mentioned above, in this project we'll be adding a new input device -- the 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, let's start with the circuit we built in the last project -- 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, and will start using "GPIOs" to control our output.

prev| next