
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 progressWhat it does
A digital output pin drives a red LED through a 220 ohm series resistor, while a push button connects a digital input pin to the 5 volt rail. A 10 kiloohm pull-down resistor holds the input at LOW while the button is open. The sketch reads the input continuously: when the button is pressed the output goes HIGH and the LED lights; when it is released the output goes LOW and the LED goes off. It is the smallest example that combines digital reading with digital driving.
Parts you need
Use the following parts to build this circuit:
- Arduino Uno × 1 — Reads the input and drives the LED.
- 220 Ω resistor × 1 — Limits the LED current safely.
- Red LED × 1 — Shows the state of the button visually.
- Push button × 1 — Connects the input pin to 5 V when pressed.
- 10 kΩ resistor × 1 — Holds the input LOW while the button is open.
- Ground connection × 1 — Common 0 V reference for the circuit.
Build it step by step
- Place the control board on your work surface.Keep it on the left so the wiring stays readable.
- Connect a 220 Ω resistor to digital output pin 1.A resistor has no polarity, so either end can go first.
- Connect the long leg of the red LED to the free end of the resistor.The long leg is the anode (+), the short leg is the cathode (-).
- Connect the short leg to ground and ground to the board GND pin.The GND pin is index 0 in the simulator pin list.
- Wire one side of the button to 5 V and the other to input pin 2.Add a second path from the same input point through a 10 kΩ resistor to ground.
- Upload the sketch and press the button; the LED lights and goes off on release.The input value can be watched as 1 and 0 in the console.
How it works
The board reads the voltage level at the digital input pin to decide the button state. Pressing the button connects the pin to 5 V, so a HIGH level (logic 1) is read. Releasing it leaves the input floating, but the 10 kiloohm pull-down resistor pulls the voltage down to 0 V and a LOW level (logic 0) is read. These two stable states let the board tell whether the button is really pressed. The sketch then sets the output pin HIGH or LOW accordingly, and the 220 ohm resistor limits the current through the LED so the component is protected. Without the pull-down resistor the input would float and random values would be read.
What you learn
- Read a digital input and drive a digital output together.
- Explain why a pull-down resistor is needed.
- Match the open and closed button states to logic 0 and 1.
- Use a series current-limiting resistor with an LED.
Tips
- If the LED stays lit while the button is open, check the pull-down connection.
- A floating input gives an unstable reading; always provide a pull path.
- If the LED never lights, the long and short legs may be reversed.
Try it yourself
- Press the button and confirm that the LED lights, then release it and confirm it goes off.
- Remove the pull-down resistor temporarily and compare how the input reading changes.
- Change the delay in the sketch and observe the response time of the LED.
Expected result: The red LED lights while the button is held down and goes off when the button is released.
Get the parts
If you want to build this project in real life, you can get the parts from hobidevre.com.
Frequently asked questions
What is this circuit for?
A digital output pin drives a red LED through a 220 ohm series resistor, while a push button connects a digital input pin to the 5 volt rail. A 10 kiloohm pull-down resistor holds the input at LOW while the button is open. The sketch reads the input continuously: when the button is pressed the output goes HIGH and the LED lights; when it is released the output goes LOW and the LED goes off. It is the smallest example that combines digital reading with digital driving.
How does it work?
The board reads the voltage level at the digital input pin to decide the button state. Pressing the button connects the pin to 5 V, so a HIGH level (logic 1) is read. Releasing it leaves the input floating, but the 10 kiloohm pull-down resistor pulls the voltage down to 0 V and a LOW level (logic 0) is read. These two stable states let the board tell whether the button is really pressed. The sketch then sets the output pin HIGH or LOW accordingly, and the 220 ohm resistor limits the current through the LED so the component is protected. Without the pull-down resistor the input would float and random values would be read.
What should I see at the end?
The red LED lights while the button is held down and goes off when the button is released.