Lab 1: Switches and Pushbuttons

Introduction

In this lab you will learn about different types of switches and their terminology. You’ll use switches and pushbuttons frequently in physical computing projects, and it’s helpful to be aware of the terminology used in describing them when shopping for them or trying to understand tutorials that use them.

An assortment of switches and pushbuttons. This image includes an arcade-style pushbutton; an old typewriter key; a round toggle switch; a small; rocker switch; a whisker switch, which is a thin wire attached to a spring wrapped around a metal post; a magnet switch, and a magnet that closes the switch when you bring it close; a tilt switch; a two-way knife switch.
Switches and pushbuttons. There are countless types of switches and pushbuttons for every purpose.

Switch Terminology

There are two common types of digital inputs: switches and pushbuttons. A switch is a mechanism that brings two pieces of metal together using some form of lever action. Think of everyday household light switches.  A pushbutton brings two pieces of metal together when you push down on it. Think of elevator buttons.

Drawing of a switch, left, and a pushbutton, right. The switch has two lines separated by a gap, with a hinged third line almost connecting them, indicating that it is the switch between the two contacts. The pushbutton has two lines separated by a gap and a third line parallel to them, indicating that, it would close the connection between the first two lines when pressed against them.
Schematic drawing of a switch and a pushbutton

Switches and pushbuttons can be normally open, meaning that when the switch is in its normal position (not being touched by a person) the contacts are not touching. Normally closed means that when the switch or pushbutton is in its normal position, the contacts are touching, or closed.

A single switch can control more than one set of contacts. A Single throw switch has only two contacts. The switch is open or closed. Dual Throw switches have three contacts, and switching the switch moves a center contact from one outer contact to  the other outer contact.

Drawing of two switch types. The top drawing has two lines separated by a gap, with a hinged third line almost connecting them, indicating that it is the switch between the two contacts. The bottom drawing has one line on the left, and two parallel lines on the right. A hinged fourth line almost connects the left line and the top right line, and indicates that it can be switched to connect the left line to the bottom right line instead.
Single throw switch, top, and dual throw switch, bottom.

Switches can have multiple poles as well. A Single pole switch has only one set of contacts that it closes or opens when it moves. Dual Pole switches have two sets of contacts being controlled by the same mechanism. With a dual pole switch, you can switch two separate circuits with the same mechanism. In a dual pole switch, the mechanism connecting the contacts is an insulator, so that the poles don’t connect. The knife switch in the image below is a dual pole, dual throw switch.

Photo of a dual-pole, dual-throw switch. The switch has a metal lever with two legs connected by a crossbar mounted at its center. On either side of the crossbar are two sets of metal contacts. When the lever is pushed to one side or the other, it will close the connection between the two metal contacts on the side toward which it is pushed. This kind of switch is sometimes called a knife switch.
Dual-pole, dual-throw switch.

Related video: Switches

Pushbuttons or momentary switches stay closed only as long as you hold them closed. Roller switches are pushbuttons with a lever and a roller attached. They’re useful when you need something to push against the switch gently to close it.

Photo of a small round button, approximately 0.5 in (2-3cm) in diameter. The button has two legs on either side. Pushing the button closes the connection between the two legs on each side.
A pushbutton
Photo of a rocker switch. A rectangular component approx. 1 in (2-3cm) wide by 0.25 in (0.5cm) thick. A lever is mounted on one side, and three metal contacts on the other. Under the lever is a small plastic protrusion that is pushed down when the lever is pressed.
A roller switch. Even though this is commonly called a switch, this is really a pushbutton. The small black protrusion under the lever is pressed down by the lever arm.

Toggle switches stay closed in one physical position and open in the other. Slide switches are similar to toggle switches.

Photo of a toggle switch. A component approx. 1.5cm wide by 0.5cm thick. There are three metal legs on one side, and a metal lever at the top center that can move from one side to the other. Moving the lever switches the center leg's connection from one side leg to the other.
Toggle switch. Moving the lever switches the center leg’s connection from one side leg to the other.
Photo of a slide switch. A component approx. 1.5cm wide by 0.5cm thick. There are three metal legs on one side, and a plastic handle at the top that can slide from one side to the other. Sliding the handle switches the center leg's connection from one side leg to the other.
Slide switch. Sliding the handle switches the center leg’s connection from one side leg to the other.
Photo of a magnet switch. A small plastic tube has one flat end and two wires protruding from the other end. Another tube of the same size contains a magnet. When the magnet tube's flat end is brought close to the switch tube's flat end, the connection is closed between the two wires.
Magnet switch.
Photo of magnet snaps. Two metal discs approx 1 inch (2.54cm) in diameter. One has a metal protrusion in the center, and the other has a depression that can fit the other's protrusion. Wires can be connected to the two snaps so that when they are snapped together, the wires are connected.
Magnet snaps. Used for clothing, wires can be connected to the two snaps so that when they are snapped together, the wires are connected. In this way, a garment fastener becomes a switch.

Magnetic switches have two metal leaves in the end that are pulled together when a magnet is brought close to them. They’re useful when you can’t have wires on both sides of the switch mechanism. Magnetic snaps are useful when you’re making a soft circuit and need a fastener on the garment to close a switch.

Photo of a whisker switch. A metal spring a few millimeters in diameter is connected to a long, thin, spring steel wire. The spring is mounted on a rubber insulation that partially covers a center post that's slightly thinner than the spring's diameter.
Whisker switch

Whisker switches are made from a piece of spring steel or piano wire, and a center post. An insulator such as a piece of electrical tape or shrink-wrap holds the two separate. When the wire is touched, the spring bends and touches the metal post, and closes the switch.

Tilt switch. This is a small tube with metal contacts at one end and a ball inside. When the ball is tilted towards the two metal contacts, it closes the switch.
Tilt switch

Tilt switches contain a metal ball and two wires at one end. Some tilt switches have one wire contact at each end instead. When you tilt the switch, the ball touches both contacts, and closes the switch. There are also mercury switches that do the same, but with a ball of mercury inside. Avoid these, since mercury is very poisonous.

Get Creative With Switches

A switch is nothing more than a mechanism to bring two pieces of conductive material together and separate them. You can make a switch from any two conductors and a little creativity.

Photo of a roll of grey fabric made of conductive threads.
Conductive fabric
Photo of copper mesh wire, approximately 4 inches (10cm) square. The mesh has holes slightly smaller than 1mm.
Copper mesh
Photo of a roll of copper tape, approximately 1cm thick. This tape is made of thin copper and has an adhesive backing.
Copper tape

All you need to do is arrange the two conductors in such a way that they can touch or not touch. Sometimes a spacer layered between the two conductors helps. For example, in the image below you see three pieces of conductive fabric. Two of the pieces have non-conductive layers on top of them. When the non-conductive part is sandwiched between the conductive layers, you’ve got a switch that’s pressed by touching. The conductive parts touch when they’re pressed through the holes in the non-conductive part. These two switches would have different sensitivities because the hole-to-material ratio of the non-conductive layer is different.

Photo of three pieces of conductive fabric. Two of the pieces have non-conductive layers on top of them.
Soft switch

 

Make your own switch. Find a way to turn a closing door into a switch, for example, or to close a switch when a person sits down. Or figure out how to turn a hat into a switch, or a cane, or a zipper. Or perhaps the pieces of a puzzle can be switches. Come up with an everyday activity to which you can add three or four custom switches that, when combined, turn on a light. For example, maybe the light comes on when you close the door, sit down, and open a book. Or when you walk upstairs, put your keys on a side table, and remove your hat. Combine your creativity with switches with what you learned in the electronics lab to make this happen. For more ideas on materials, check out How to Get What You Want. They have an excellent list of conductive materials and instructions.

Here’s mustache switch by Tak Cheung:

Arrangements of switches

In planning your switch project, consider what happens when you arrange switches in different ways. For example, try the following circuits.

Project 1: Three switches in parallel

Three switches in parallel. Any one of the three will turn on the LED.

Drawing of three parallel switches. At the top left of the drawing there is a power supply. The positive line from the power supply connects to a 7805 5-volt voltage regulator's input. The power supply's ground is connected to the regulator's ground. The output of the regulator connects to a 220-ohm resistor. The other side of the resistor connects to one side of a switch. That side is connected to two other switches below it. The other sides of all three switches are connected to each other, and then to the anode (positive side) of an LED. The cathode (negative side) of the LED is connected to the ground of the voltage regulator.
Schematic view of three parallel switches connected to an LED.
Breadboard drawing of three parallel switches. At the top of the drawing,there is a DC power jack. Red and black wires from the jack connect to a 7805 5-volt voltage regulator mounted in the top right three rows of the breadboard with its tab facing to the right. input. The power supply's red wire is connected to the regulator's top pin row, the input pin. The power supply's black wire is connected to the regulator's middle pin, or ground. Another black wire connects the regulator's middle pin, ground, to the inner left side row of the board. This is the ground bus on the left side. A red wire connects the regulator's bottom pin, the output pin, to the outer left side row of the board. This is the voltage bus on the left side. At the bottom of the breadboard, a red wire connects the left side voltage bus to the inner row on the right side. This is the right side voltage bus. Similarly, a black wire connects the left side ground bus to the outer row on the right side. This is the right side ground bus. A 220-ohm resistor connects the the left side voltage bus to row 8 in the left center section of the board. A pushbutton is mounted across the center divide of the breadboard with its pins in rows 8 and 10. Another pushbutton is mounted across the center in rows 13 and 15, and a third in rows 18 and 20. In the left center section of the board, four short wires connect the top row connection of each pushbutton to the top row of the next pushbutton. Specifically: row 8 connects to row 13. Row 13 connects to row 18. Row 10 connects to row 15. Row 15 connects to row 20. In the right center section of the board, an LED's anode (long leg) is connected to row 20. The LED's cathode is connected to row 21, and a black wire connects from that row to the right side ground bus.
Switches in parallel, breadboard view.

Project 2: Three switches in series

Three switches in series. All three must be on to turn on the LED.

Drawing of three switches in series. At the top left of the drawing there is a power supply. The positive line from the power supply connects to a 7805 5-volt voltage regulator's input. The power supply's ground is connected to the regulator's ground. The output of the regulator connects to a 220-ohm resistor. The other side of the resistor connects to one side of a switch. The other side of the switch connects to a second switch. The other side of that switch connects to a third switch. The other side of the third switch connects to the anode (positive side) of an LED. The cathode (negative side) of the LED is connected to the ground of the voltage regulator.
Schematic view of three switches in series connected to an LED.
Breadboard drawing of three switches in series connected to an LED. At the top of the drawing, there is a DC power jack. Red and black wires from the jack connect to a 7805 5-volt voltage regulator mounted in the top right three rows of the breadboard with its tab facing to the right. input. The power supply's red wire is connected to the regulator's top pin row, the input pin. The power supply's black wire is connected to the regulator's middle pin, or ground. Another black wire connects the regulator's middle pin, ground, to the inner left side row of the board. This is the ground bus on the left side. A red wire connects the regulator's bottom pin, the output pin, to the outer left side row of the board. This is the voltage bus on the left side. At the bottom of the breadboard, a red wire connects the left side voltage bus to the inner row on the right side. This is the right side voltage bus. Similarly, a black wire connects the left side ground bus to the outer row on the right side. This is the right side ground bus. A 220-ohm resistor connects the the left side voltage bus to row 8 in the left center section of the board. A pushbutton is mounted across the center divide of the breadboard with its pins in rows 8 and 10. Another pushbutton is mounted across the center in rows 13 and 15, and a third in rows 18 and 20. In the left center section of the board, two short wires connect one side of each pushbutton to the other side of the next pushbutton. Specifically: row 10 connects to row 13. Row 15 connects to row 18. In the right center section of the board, an LED's anode (long leg) is connected to row 20. The LED's cathode is connected to row 21. A black wire connects row 21 to the right side ground bus.
Breadboard view of three switches in series connected to an LED.

Through a combination of series and parallel switches, you can come up with a variety of combinations that make the light turn on. Depending on where you add the LEDs, you can even have the same switches turn on different LEDs in different combinations. Try a few combinations and see what happens.

Project 3: Switching a motor

In a simple circuit, a motor is no different than an LED as a load. You can switch it as well. Make sure your power supply can supply the current and amperage that your motor requires and you are good to go.

Drawing of a dual-pole switch controlling a motor and an LED. At the top left of the drawing there is a power supply. The positive line from the power supply connects to a 7805 5-volt voltage regulator's input. The power supply's ground is connected to the regulator's ground. The output of the regulator connects to one side of a switch. The other side of the switch connects to a DC motor. The other side of the motor connects to ground.
Schematic view of a motor switched by a pushbutton.
ard drawing of a pushbutton controlling a motor. At the top of the drawing, there is a DC power jack. Red and black wires from the jack connect to a 7805 5-volt voltage regulator mounted in the top right three rows of the breadboard with its tab facing to the right. The power supply's red wire is connected to the regulator's top pin row, the input pin. The power supply's black wire is connected to the regulator's middle pin, or ground. Another black wire connects the regulator's middle pin, ground, to the inner left side row of the board. This is the ground bus on the left side. A red wire connects the regulator's bottom pin, the output pin, to the outer left side row of the board. This is the voltage bus on the left side. At the bottom of the breadboard, a red wire connects the left side voltage bus to the inner row on the right side. This is the right side voltage bus. Similarly, a black wire connects the left side ground bus to the outer row on the right side. This is the right side ground bus. A red wire connects the the left side voltage bus to row 13 in the left center section of the board. A pushbutton is mounted across the center divide of the breadboard with its pins in rows 13 and 15. A DC motor is connected to row 15 in the left center section of the board. The other wire from the motor is attached to the voltage bus on the left side of the board.
Breadboard view of a motor connected to a switch.

With a dual pole switch, you could control both a motor and an LED. The small square pushbuttons that come with many kits for Arduino are dual pole switches. The left side of the switch and the right side of the switch can switch different loads, like so:

Drawing of a dual-pole switch controlling a motor and an LED. At the top left of the drawing there is a power supply. The positive line from the power supply connects to a 7805 5-volt voltage regulator's input. The power supply's ground is connected to the regulator's ground. The output of the regulator connects to one side of a switch. The other side of the switch connects to a DC motor and to a 220-ohm resistor in parallel. The other side of the motor connects to ground. The other side of the resistor connects to the anode of an LED. The other side of the LED connects to ground.
Schematic view of a motor and an LED switched by a dual-pole pushbutton (switch).
Breadboard drawing of a dual-pole pushbutton (switch) controlling a motor and an LED. At the top of the drawing, there is a DC power jack. Red and black wires from the jack connect to a 7805 5-volt voltage regulator mounted in the top right three rows of the breadboard with its tab facing to the right. input. The power supply's red wire is connected to the regulator's top pin row, the input pin. The power supply's black wire is connected to the regulator's middle pin, or ground. Another black wire connects the regulator's middle pin, ground, to the inner left side row of the board. This is the ground bus on the left side. A red wire connects the regulator's bottom pin, the output pin, to the outer left side row of the board. This is the voltage bus on the left side. At the bottom of the breadboard, a red wire connects the left side voltage bus to the inner row on the right side. This is the right side voltage bus. Similarly, a black wire connects the left side ground bus to the outer row on the right side. This is the right side ground bus. A red wire connects the the left side voltage bus to row 13 in the left center section of the board. A pushbutton is mounted across the center divide of the breadboard with its pins in rows 13 and 15. A DC motor is connected to row 15 in the left center section of the board. The other wire from the motor is attached to the voltage bus on the left side of the board. In the right center section of the board, a 220-ohm resistor is connected to row 15. The other side of the resistor is connected to row 19. The anode (long leg) of an LED is connected to row 19 as well. The cathode (short leg) of the LED is connected to row 20. A black wire connects row 20 to the right side ground bus.
Breadboard view of a dual-pole pushbutton (switch) controlling a motor and an LED.

You’ll learn more about controlling motors from a microcontroller in later labs.

Originally written on July 18, 2014 by Benedetta Piantella Simeonidis
Last modified on September 21, 2018 by Regina Sofia Cantu de Alba