Arduino Circuits

LED Control with a Pull-up Button

Control a green LED using a pull-up button input built with an external pull-up resistor.

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

Bu projeyi gerçekten kurmak istersen parçaları hobidevre.com'dan temin edebilirsin →

Build it for real

To build this project for real, get the parts from hobidevre.com → hobidevre.com →

More build guides: hobidevre.com/blog

Create a free account — save your progress and get more circuits →

Save your progress

What is it for?

In this circuit, the button is connected between a digital input pin and ground. The same input point is pulled to the 5-volt rail through a 10-kilohm resistor. When the button is not pressed, the input pin reads HIGH through this resistor; when the button is pressed, the pin is connected directly to ground and reads LOW. The software interprets the LOW value as the button being pressed and lights the green LED. The LED is fed from a separate output pin through a 220-ohm series resistor. This arrangement shows the working principle of an external pull-up resistor and teaches how to keep an input pin from floating. The same logic is used in most sensor and switch inputs.

Parts list

The following components are used to build this project:

  • Arduino Uno — Reads the input level and drives the LED.
  • Button — Pulls the input to ground when pressed.
  • 10kΩ Resistor — Keeps the input at HIGH level while the button is released.
  • 220Ω Resistor — Limits the current through the LED.
  • Green LED — Shows the pressed state of the button.
  • Ground — Common 0-volt reference.

Step-by-step build

  1. Place the board and put the button on the lower row.Connect one end of the button directly to the ground rail.
  2. Add the 10-kohm resistor between the 5-volt rail and the button's input end.Without this resistor the input would float.
  3. Connect the same input node to input pin 1 of the board.The resistor and the button must meet at the same node.
  4. Connect the 220-ohm resistor and the green LED from output pin 2 to ground.The LED anode goes to the resistor, the cathode to ground.
  5. Connect the ground rail to the board's GND pin.One common reference makes the whole circuit stable.
  6. Upload the code; the green LED lights up when the button is pressed.The code should treat the LOW state as pressed.

How it works

In a pull-up arrangement, the input pin is held connected to the supply voltage through a 10-kilohm resistor. When the button is open, about 5 volts is present and the board reads HIGH (logic 1). When the button is pressed, the pin is connected directly to ground; this low-resistance path overrides the 10-kilohm resistor and the pin drops to LOW (logic 0). The software interprets this LOW value as the button being pressed and lights the LED. The resistor's job is to prevent the pin from floating when the button is open and to create two stable states. The same method is used in many switch and sensor circuits that require an external pull-up.

The button is on the lower row and one end goes to the ground rail. The 10-kohm pull-up resistor extends from the same input node to the 5-volt rail. The green LED and the 220-ohm resistor are on the output line in the upper row; the LED cathode and the button's ground end meet on the common rail.

What you will learn

  • Explains how a pull-up resistor stabilises an input.
  • Applies active-low button logic in code.
  • Knows why a floating input causes problems.
  • Interprets the effect of resistor value on reading stability.

Tips

  • If the LED works backwards, check the code for HIGH instead of LOW.
  • If the pull-up resistor is too small, unnecessary current flows while the button is pressed.
  • If the input reading flickers, review the wires and the common ground.

Try it yourself

  • Compare the digital value read when the button is pressed and released.
  • Drive the LED in the correct direction using active-low logic in the code.
  • Remove the pull-up resistor and observe how the input reading breaks down.

Getting the parts

Frequently asked questions

What does this circuit do?

Control a green LED using a pull-up button input built with an external pull-up resistor.

How does the circuit work?

In a pull-up arrangement, the input pin is held connected to the supply voltage through a 10-kilohm resistor. When the button is open, about 5 volts is present and the board reads HIGH (logic 1). When the button is pressed, the pin is connected directly to ground; this low-resistance path overrides the 10-kilohm resistor and the pin drops to LOW (logic 0). The software interprets this LOW value as the button being pressed and lights the LED. The resistor's job is to prevent the pin from floating when the button is open and to create two stable states. The same method is used in many switch and sensor circuits that require an external pull-up.

What is the expected result?

The green LED lights up when the button is pressed and goes out when it 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.