Instead of constantly polling a button, it is more efficient for the hardware to notify the board when an event happens. In this circuit the button connects to a digital pin that supports interrupts. A pull-up resistor holds the pin HIGH while idle; pressing the button pulls the pin to ground and creates the interrupt. The board pauses its current work, enters a short response routine, changes the LED state and then continues where it left off. A second LED shows that the main loop keeps running. The circuit teaches event-driven programming and instant response.

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 →
No installationYou can open this circuit in the browser simulator, trace the connections and change values to see what happens.
Open in simulatorParts you need
Build the circuit with the components below. Each component’s role is listed in the parts list.
- Control board × 1 — Handles the interrupt event and drives the LEDs.
- Button × 1 — Produces the event that triggers the interrupt.
- 10kΩ resistor × 1 — Holds the pin HIGH while idle.
- 220Ω resistor × 2 — Limits the current of the LEDs.
- Amber LED × 1 — Changes state when an interrupt occurs.
- Green LED × 1 — Shows that the main loop is running.
- +5V power rail × 1 — Supplies voltage to the pull-up resistor.
Build steps
Placement on the breadboard: the control board is on the left; the button and 10kΩ pull-up resistor are at the top centre (rows 4-7), with the interrupt line going to board pin 2. The amber LED is at the lower left and the green LED at the lower right; each LED has its own 220Ω resistor. All ground pins are on the bottom rail.
- Place the control board and connect its GND pin to the bottom rail. Tip: Pin 2 is suitable for the interrupt.
- Add the button at the top centre and connect one end to ground. Tip: The other end goes to the interrupt line.
- Place the 10kΩ pull-up resistor between +5V and the button’s signal pin. Tip: Without this resistor the pin floats.
- Connect the button’s signal pin to board pin 2. Tip: At the moment of the press the pin is pulled to ground.
- Connect the amber and green LEDs with separate 220Ω resistors to pins 3 and 4. Tip: Each LED’s cathode goes to ground.
- Press the button in the simulation and watch the amber LED change instantly. Tip: The green LED keeps blinking even during the interrupt.
How it works
An interrupt lets the processor pause the running program and jump to a special routine. When the button is pressed the pin level drops from HIGH to LOW and the hardware flags this as an interrupt request. The processor stops its current task, enters the interrupt routine, changes the LED state and returns; the main loop continues where it left off. The pull-up resistor keeps the pin at a defined HIGH level when the button is not pressed; otherwise the pin would pick up stray fluctuations. Mechanical buttons bounce for a few milliseconds when pressed; a short software delay or a hardware filter removes this bounce. This structure shows an event-driven response model instead of continuous polling.
Expected result
On every button press the amber LED switches instantly; the green LED keeps blinking regularly.
Tips and common mistakes
- Without a pull-up resistor the LED may change on its own.
- Keep the interrupt routine as short as possible.
- Button bounce produces several interrupts; add a short delay.
- Use only pins that support interrupts as the interrupt pin.
Try it yourself
- Change the amber LED state when the button is pressed.
- Observe that the green LED runs without interruption during an interrupt.
- Change the debounce delay and compare the behaviour.
What you learn in this circuit
- Compares interrupts with continuous polling.
- Explains how a pull-up resistor stabilises the pin state.
- Builds the habit of writing a short interrupt routine.
- Justifies the effect of button bounce.
Finding the parts
If you want to build this project in real life, you can get the parts from hobidevre.com.
Looking for more project ideas? Browse the guides on the hobidevre.com blog.