Buttons and switches are basic parts found in many physical user interfaces. They come in many shapes (form factors) and sizes. Switches and buttons can be used in stand alone electronic situations or combined with code (Digital Inputs). This Building Block will introduce you to the two basic examples of buttons and switches that we have in our kits.
Switch Basics
Find the basic switches in your kit and set them out in front of you. You should be able to find push buttons (left) and slide switches ( right ). Once you have them out explore the switches, get a feel for how they move and slide.
What are Switches?
Switches are devices that allow us to make and break connections within a circuit. Our switches are small and can only switch small voltages (5V or 9V max) and current (milliAmp level – mA). We will use them to control inputs into our Arduino.
Switch Representations
As mentioned above, switches come in many shapes and sizes. While we can represent switches in many ways, you will commonly see the following symbol to indicate a simple switch.
More complex switches will reorganize the above symbol to reflect their internal connection patterns.
You may also see more diagrammatic versions of the switch. These indicate something about the physical structure as well as the electrical connections.
I may use the following for push buttons :
And this for our slide switches.
Let’s explore our switches in circuits to build an understanding of how they work and what they do.
Required Parts
- switch
- button
- breadboard
- LED
- 470 ohm resistor (current limiting resistor)
- battery pack
- wire battery clip
slide switch
Video
Please note — In an effort to reduce e-waste we decided to no longer include the 37-sensor set (mentioned in the video) in every individual kit. Many of these were not used by most students. These kits are available to borrow from the makerSpace (post-Covid, once we return to campus).
Get the slides
Building A Switch Circuit
Here is a simple circuit that can be used to illustrated how switches work. It is also a great circuit to test a switch’s function independent of code.
Using a Switch as a Digital Input
Switches are key elements in making digital inputs to an Arduino (or any microcontorller). For this cicrcuit, you will need a breadboard, a 10K and a 1k resistor and a jumper wire.
Here is the circuit:
For a full explanation of this circuit refer to your digital input cheat sheet ! You can also find a lot more information at the Digital Input page.
Going Further
Switches come with a truly impressive amount of jargon. It is very specific, and once you get over the shock, actually useful. But it can make getting to know these devices overwhelming. In the sections below, i will intorduce you to some terminology you may encounter as you go further.
Momentary / Maintained
Switches may be distinguished by the kinds of movents built into them. Momentary switches are those that ‘bounce back’ or return to their starting position when released. Our buttons are momntary.
Maintained switches, hold their position when released. You can feel this action with our slide switches.
There are some switches, such as those in relays, that are momentary but are controlled by elecrticity — not human engagement.
Normally Open / Normally Closed
Momentary swiches amy also be categorized by their electrical state when not pressed. Our buttons for example are OPEN when not pressed and CLOSED when we force the plunger down. THey are called Normally Open (NO).
Some button are closed when resting and are opened when we press them down. These are called Normally Closed (NC).
WHile the wiring for these will be similar, think about how this affect circuit behaviour. A normally closed switch will allow curent to flow when NOT pressed. While a normally open switch will only allow current to lfow when pressed (closed).
Throws / Poles
More abstract and advanced is the idea of poles and throws. Poles indicated the number of circuits a device can controlled. Throws indicates the number of postions to which the poles can be connected.
Our buttons are very simple single pole (one circuit), single throw (one postiion) switches. We abbreviated this SPST.
Our slides are single pole (one cirucit), double throw (two positons) — or SPDT.
Learn alot more about poles and throws in the links below.