Button and Switch Basics

Pages
Contributors: jimblom
Favorited Favorite 55

Switch Applications

On/Off Control

Among the most obvious of switch applications is simple on and off control. The type of control you perform every time you walk into a dark room. An on/off switch can be implemented by simply sticking an SPST switch in series with a power-line. Usually the on/off switch will be maintained, like a toggle or slide switch, but momentary on/off switches can have their purpose.

Example on/off circuit

On this Breadboard Power Supply, an SPDT switch is used to turn the circuit on and off. (A second SPDT switch is used to select the adjustable voltage regulator's output value by adjusting a voltage divider.)

When implementing such a switch, keep in mind that all the current your project consumes is going to run through that switch. Ideally a switch is a perfect conductor, but realistically it's got a small amount of resistance between the two contacts. Because of that resistance, all switches are rated for a maximum amount of current they can withstand. Exceed a switch's maximum current rating, and you can expect melted plastic and magic smoke.

For example, this SPDT slide switch is great for controlling current flow in small projects (like Simons or Metronomes), but don't try using it to control beefy motor controllers, or strings of 100 LEDs. For that, consider using something like a 4A toggle switch or a 6A lamp switch.

User Input

Of course, user input is one of the more common applications for switches. For example, if you want to connect a switch to a microcontroller input pin, a simple circuit like this is all you'd need:

Switch into MCU and a pull-up resistor

When the switch is open, the MCU pin is connected through the resistor to 5V. When the switch is closed, the pin is tied directly to GND. The resistor in that circuit is a pull-up resistor, required to bias the input high, and prevent a short to ground when the switch is closed.