Buttons and Switches

Learn the difference between a momentary button and a latching switch, and control a circuit with a button.

LESSON COMPASS

What will you use this page for?

Core idea

Buttons and switches are simple but very important parts that open or close the path of a circuit, deciding whether electricity is allowed to flow.

Evidence to produce

Complete the page task with your own input, test conditions and reasoning.

Control trap

Using the wrong legs of the button On most four-legged buttons, the legs are already joined in pairs inside. If you pick the wrong pair, the button acts as if it is never pressed, or always pressed. Before wiring, check which legs are the actual "button." Forgetting the resistor Connecting the LED straight to the…

Next connection

Potentiometer: You will meet the adjustable resistor that raises and lowers a value gradually, and see how it can smoothly change the brightness of an LED.

Module sources: Python Tutorial · Arduino Learn

LevelBeginner
Age10–16
Duration35–50 min
PrerequisiteUsing LEDs and Resistors
ContentIn-depth guide · 1,907 words
Last updated

One-sentence summary

Buttons and switches are simple but very important parts that open or close the path of a circuit, deciding whether electricity is allowed to flow.

Why does it matter?

In the previous lesson we lit an LED with a resistor. But there the LED stayed on the whole time the power was connected. In real devices we want to turn something on and off at the moment we choose. The button that turns on a light, the key that rings a bell and the trigger on a game controller all rely on the same idea.

A switch is the part that opens or closes the path in a circuit. When the path is closed off, electricity cannot pass and the LED stays dark. When the path is open, electricity flows and the LED lights up.

By the end of this lesson you will design, on paper, an LED circuit that turns on when you press a button and off when you let go. You will also understand how a computer or a micro:bit "reads" whether a button is pressed.

How does a circuit open and close?

Think of a circuit as a single water pipe. Water flows when every part is connected. If we add a valve, closing it stops the water and opening it lets the water flow again.

A switch works exactly like that valve. It has two metal ends. If they touch, the circuit is complete and electricity flows. If they are apart, there is a gap and electricity cannot flow.

The words here can be confusing, so read carefully:

As a schematic

Below is a text schematic of a circuit made from a battery, a button, a resistor and an LED. Electricity leaves the positive (+) end of the battery, travels around the loop and returns to the negative (−) end.

[Battery +] --- [Button] --- [Resistor] --- [LED anode +]
                                                 |
[Battery -] --------------------------------- [LED cathode -]

When the button is not pressed, the two ends inside it are apart. The loop is not complete, so the LED does not light. When you press the button, the two ends join, the loop is completed and the LED turns on.

Momentary button or latching switch?

Not all switches behave the same way. We can sort them into two big groups.

Momentary button

A momentary button keeps the circuit closed only while you press it. The moment you lift your finger, a small spring pushes the ends apart again and the circuit opens.

Everyday example: a doorbell. It rings while you hold the button and stops when you let go. Every key on a keyboard is also a momentary button.

Latching switch

A latching switch stays in a position once you move it. It keeps its open or closed state until you move it again.

Everyday example: the wall light switch in your room. Flip it once and the light stays on; flip it again and it turns off. The sliding switch on a flashlight works the same way.

This table compares the two types:

Latching switch table
FeatureMomentary buttonLatching switch
While pressedCircuit is closedChanges position
When releasedCircuit opensStays in the same position
ExampleDoorbell, keyboard keyLight switch, flashlight slider
UseShort commandSteady on/off

Which one you choose depends on the goal. For "spin only while I hold the button," a momentary button makes sense. For "turn it on once and leave it," a latching switch fits better.

How is a button connected to a computer?

So far the button directly opened and closed the path between the LED and the battery. But with a board like a micro:bit or an Arduino, the button usually does not power the light directly. Instead, the board reads whether the button is pressed and decides what to do.

The board looks at the voltage on one of its legs (a pin):

Here is the catch: when the button is not pressed, the pin might not be connected to anything. This state is called "floating." A floating pin can read 1 sometimes and 0 other times because of nearby electrical noise, so it is unreliable.

The pull-down resistor idea

To prevent this, we give the pin a gentle path. A pull-down resistor gently pulls the pin toward 0 (the negative end) whenever the button is not pressed. Its name means "pulls down."

3V ----------------------[Button]--------+---- Pin (board reads)
                                         |
                                  [Resistor ~10k]
                                         |
                                        GND (0V)

The resistor is usually large (for example 10 kilo-ohms, that is 10,000 ohms). Such a large value keeps any wasted current tiny but still holds the pin at a steady 0.

The pull-up resistor idea

We can flip the same idea. A pull-up resistor gently pulls the pin toward 1 (the positive end) whenever the button is not pressed. In this arrangement the pin reads 0 when you press. It may sound surprising, but many boards prefer this because it resists noise better.

At this stage remember just one thing: a floating pin is unreliable; a pull-down or pull-up resistor makes it steady. The direction of the numbers becomes clear later, with practice.

Mini practice

Do this practice together with an adult, using battery power only.

Goal: Build an LED circuit that turns on when you press a button and turns off when you release it (on paper or on a breadboard).

Materials:

Let's check the resistor with Ohm's law, as in the previous lesson. About 2 volts drop across a red LED, so the remaining voltage is:

Battery voltage    = 3 V
Voltage across LED  = 2 V
Left for resistor  = 3 V - 2 V = 1 V

Resistor = leftover voltage / target current
         = 1 V / 0.01 A
         = 100 ohms

So 100 ohms is a good choice for about 10 milliamps (0.01 amps).

Steps:

  1. Run a wire from the positive end of the battery holder.
  2. Connect this wire to one leg of the button.
  3. Connect the other leg of the button to the resistor.
  4. Connect the other end of the resistor to the long leg of the LED (anode, +).
  5. Connect the short leg of the LED (cathode, −) to the negative end of the battery holder.
  6. Press the button and watch the LED light up. Lift your finger; the LED should go dark.

Schematic:

[Battery +] -> [Button] -> [Resistor 100Ω] -> [LED long leg +]
[Battery -] <----------------------------------- [LED short leg -]

Things to try:

Common mistakes

Using the wrong legs of the button

On most four-legged buttons, the legs are already joined in pairs inside. If you pick the wrong pair, the button acts as if it is never pressed, or always pressed. Before wiring, check which legs are the actual "button."

Forgetting the resistor

Connecting the LED straight to the battery repeats the mistake from the previous lesson. Without a current-limiting resistor, the LED can be damaged. A button does not remove the need for a resistor.

Forgetting about the floating pin

If you connect a button to a board without a pull-down or pull-up resistor, the board may read it as pressed sometimes and not pressed other times. The program looks like it runs "by itself," but the real problem is the floating pin.

Mixing up open and closed circuits

In everyday language "open" can mean working. But in electronics an open circuit is one where the path is broken and electricity does not flow. A closed circuit is the one where current flows.

Safety note

Lesson summary

Review questions

  1. What is the difference between a closed circuit and an open circuit?
  2. What is the main difference between a momentary button and a latching switch? Give an example of each.
  3. Why is a resistor still needed in an LED circuit that lights when you press a button?
  4. How does a board tell whether a button is pressed?
  5. What is the job of a pull-down resistor?

Answers

  1. In a closed circuit the path is complete and electricity flows (the LED is on). In an open circuit there is a gap in the path, so electricity does not flow (the LED is off).
  2. A momentary button keeps the circuit closed only while you hold it (for example a doorbell). A latching switch stays in the position you set until you change it (for example a wall light switch).
  3. The resistor limits the current. Without it, too much current can flow through the LED and damage it. The button only opens and closes the path; it does not limit current.
  4. The board looks at the voltage on the pin connected to the button. If the voltage is high it reads 1, and if it is near zero it reads 0, so it can tell whether the button is pressed.
  5. A pull-down resistor steadily pulls the pin to 0 (to GND) while the button is not pressed. This keeps the pin from floating and reading random values.

Source and verification note

For “Buttons and Switches”, verification focuses on whether the relationship between How does a circuit open and close? and Momentary button or latching switch? remains consistent across examples. Activities are designed only for low-voltage direct-current circuits; mains electricity is not used. Component values must be rechecked for the actual circuit, and connections should be reviewed with an adult before power is applied.

Next lesson

Potentiometer: You will meet the adjustable resistor that raises and lowers a value gradually, and see how it can smoothly change the brightness of an LED.

Start QuizBack to Introduction to Electronics
QUESTION POOL

Reinforce this lesson with 10 questions

This lesson has a pool of 20 questions. Each attempt selects 10 and reshuffles the choices.