Arduino Circuits

Button-Controlled LED

A basic input-output circuit that uses a button and a pull-down resistor to turn an Arduino output LED on and off.

November 22, 20264 min read
Button-Controlled LED — Arduino circuit built on a breadboard, showing components and connections
Button-Controlled LED circuit breadboard layout, components and jumper connections.

Interactive circuit guide

Run the simulation, follow the build steps one by one and try it in our real app.

Real screenshot of our circuit simulator Stopped
Open in our app →

Step-by-step build

What is it for?

In this circuit, one digital output pin of the control board is connected to a red LED through a 220-ohm series resistor. The cathode leg of the LED goes to common ground. One end of the button is connected to the board's 5-volt rail and the other end to a digital input pin. Pulling this input pin to ground through a 10-kilohm resistor keeps the signal from floating when the button is not pressed. The code reads the button state continuously; when pressed it sets the output pin HIGH and the LED lights up, and when released it sets the pin LOW and the LED goes out. This circuit is the simplest example of using digital reading and digital driving together, and it forms the basis of more complex sensor and alarm projects.

Parts list

The following components are used to build this project:

  • Arduino Uno — The control board that reads the input and drives the LED.
  • 220Ω Resistor — Safely limits the current through the LED.
  • Red LED — Visually shows the button state.
  • Button — Connects the input pin to 5 volts when pressed.
  • 10kΩ Resistor — Holds the input at LOW level while the button is released.
  • Ground — The circuit's common 0-volt reference.

Step-by-step build

  1. Place the control board on the work surface.Lean the board to the left so the connections are easy to see.
  2. Connect the 220-ohm resistor to output pin 1 of the board.Both ends of the resistor are symmetrical, so orientation does not matter.
  3. Connect the long leg of the red LED to the free end of the resistor.The long leg is the anode (+), the short leg the cathode (-).
  4. Connect the short leg of the LED to ground, and ground to the board's GND pin.The GND pin appears as index 0 in the pin list.
  5. Connect one end of the button to the 5-volt rail and the other end to input pin 2.Run a second path from the same input point through a 10-kohm resistor to ground.
  6. Upload the code and press the button; the LED lights up and goes out when released.The input value can be followed as 1 and 0 in the console.

How it works

The control board determines the button state by reading the voltage level at the digital input pin. When the button is pressed, the pin is connected to 5 volts and HIGH (logic 1) is read. When the button is released, the input end is left floating; thanks to the 10-kilohm pull-down resistor the voltage is pulled to 0 volts and LOW (logic 0) is read. These two stable states let the board clearly understand whether the button is actually pressed. The software sets the output pin HIGH or LOW according to the state it reads; the 220-ohm resistor limits the current through the LED to protect the component. Without the pull-down resistor, the input would float and random values would be read.

The control board is on the left. The 220-ohm resistor and the red LED go on the upper row, while the button and the 10-kohm resistor go on the lower row. The LED cathode, one end of the pull-down resistor and the board's GND pin meet on the common ground rail; the 5-volt end of the button goes to the board's power rail.

What you will learn

  • Applies digital input reading and digital output driving together.
  • Explains why a pull-down resistor is necessary.
  • Maps the open and closed states of a button to logic 0 and 1.
  • Uses a series current-limiting resistor for the LED.

Tips

  • If the LED is lit while the button is not pressed, check the pull-down resistor connection.
  • If the input pin is left floating, the reading becomes unstable; always add a pull path.
  • If the LED never lights up, you may have reversed the long and short legs.

Try it yourself

  • Observe that the LED lights up when you press the button and goes out when you release it.
  • Temporarily remove the pull-down resistor and compare how the input reading breaks down.
  • Change the delay in the code and observe the LED's response time.

Getting the parts

Frequently asked questions

What does this circuit do?

A basic input-output circuit that uses a button and a pull-down resistor to turn an Arduino output LED on and off.

How does the circuit work?

The control board determines the button state by reading the voltage level at the digital input pin. When the button is pressed, the pin is connected to 5 volts and HIGH (logic 1) is read. When the button is released, the input end is left floating; thanks to the 10-kilohm pull-down resistor the voltage is pulled to 0 volts and LOW (logic 0) is read. These two stable states let the board clearly understand whether the button is actually pressed. The software sets the output pin HIGH or LOW according to the state it reads; the 220-ohm resistor limits the current through the LED to protect the component. Without the pull-down resistor, the input would float and random values would be read.

What is the expected result?

The red LED lights up while the button is pressed and goes out when the button is released.

You may also like

Try the circuit in the simulator

Open the diagram in your browser, inspect the connections and follow the steps.