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:
- Closed circuit: The path is complete, electricity flows, the LED is on.
- Open circuit: There is a gap in the path, electricity does not flow, the LED is off.
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:
| Feature | Momentary button | Latching switch |
|---|---|---|
| While pressed | Circuit is closed | Changes position |
| When released | Circuit opens | Stays in the same position |
| Example | Doorbell, keyboard key | Light switch, flashlight slider |
| Use | Short command | Steady 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):
- If the voltage is high (for example 3 volts), it reads this as 1.
- If the voltage is near zero, it reads this as 0.
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)
- Button not pressed: the pin is connected to GND through the resistor, so it reads 0.
- Button pressed: the pin is connected directly to 3V, so it reads 1.
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:
- 2 AA batteries and a battery holder (3 volts total)
- 1 momentary button
- 1 LED
- 1 resistor of 100 ohms
- Connecting wires
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:
- Run a wire from the positive end of the battery holder.
- Connect this wire to one leg of the button.
- Connect the other leg of the button to the resistor.
- Connect the other end of the resistor to the long leg of the LED (anode, +).
- Connect the short leg of the LED (cathode, −) to the negative end of the battery holder.
- 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:
- If you replaced the momentary button with a latching switch, how would the behaviour change?
- If you placed the button after the resistor instead of before it, would the circuit still work? (It would; the order does not matter, because everything is in one single loop.)
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
- Use only low-voltage, educational sources: AA batteries (3 volts), USB, a micro:bit or an Arduino. Never work with mains electricity, wall sockets or exposed wiring. Sockets are dangerous for experiments like these.
- Always use batteries, motors and cutting tools under an adult's supervision.
- Connect polarity correctly: plus to plus, minus to minus. A reversed connection can damage some parts.
- Never connect a battery's positive and negative ends directly with a wire; this is a short circuit and batteries can heat up. Lithium batteries in particular can overheat when short-circuited, so we recommend simple AA batteries here.
- If any part starts to get warm, disconnect the power at once and tell an adult.
Lesson summary
- Switches and buttons let electricity flow or block it by opening and closing the circuit's path.
- In a closed circuit electricity flows and the LED lights; in an open circuit it does not and the LED is dark.
- A momentary button is closed only while pressed; a latching switch holds its state until you move it again.
- When a board reads a button, it looks at the pin's voltage and interprets it as 1 or 0.
- A pull-down or pull-up resistor makes a floating pin steady; a resistor is still needed in button circuits.
Review questions
- What is the difference between a closed circuit and an open circuit?
- What is the main difference between a momentary button and a latching switch? Give an example of each.
- Why is a resistor still needed in an LED circuit that lights when you press a button?
- How does a board tell whether a button is pressed?
- What is the job of a pull-down resistor?
Answers
- 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).
- 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).
- 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.
- 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.
- 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.