Simple delay commands make the processor wait and stop other tasks. In this circuit elapsed time is kept as a timestamp instead; each task stores the moment it last ran. When the timestamp reaches the chosen interval the relevant LED is switched on or off and the record is updated. In this way a fast and a slow LED work at the same time without blocking one another, and the button state is read in the same loop. The circuit teaches the basic model of non-blocking timing and multi-task scheduling. When the timestamp value wraps around, long measurements can shift; this should be considered from the start.

Interactive circuit guide
Run the simulation, follow the build steps one by one and try it in our real app.
Stopped
Step-by-step build
You 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 — Schedules tasks using timestamps.
- Button × 1 — Triggers an extra task.
- 10kΩ resistor × 1 — Pulls the button line up.
- 220Ω resistor × 2 — Protects the LEDs by limiting current.
- Red LED × 1 — Represents the short-interval task.
- Blue LED × 1 — Represents the long-interval task.
- +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 3-6), with the signal pin going to board pin 2. The red LED and 220Ω resistor are at the lower left, the blue LED with its own 220Ω resistor at the lower right. All ground pins meet on the bottom rail.
- Place the control board and connect its GND pin to the bottom rail. Tip: All tasks run on the same board.
- Set up the button and 10kΩ pull-up at the top centre and connect the signal pin to pin 2. Tip: The button’s other end goes to ground.
- Connect the red LED with a 220Ω resistor to pin 3. Tip: This LED represents the short-interval task.
- Connect the blue LED with its own 220Ω resistor to pin 4. Tip: This LED represents the long-interval task.
- Define a last-run time variable for each task. Tip: Reset the elapsed-time value at startup.
- In the loop, check whether the interval has elapsed and update the LEDs. Tip: Do not use a delay command; let the loop keep running.
- In the simulation, watch the two LEDs blink at different rhythms and the button being detected. Tip: Change the intervals to observe overlap.
How it works
Non-blocking timing is based on storing elapsed time as a timestamp. Each task keeps its own last-run moment; on every pass the loop calculates the difference between the current time and that record. When the difference equals or exceeds the given interval the task runs and the record is updated. Because no wait command is used, the processor keeps checking other tasks; the fast and slow LEDs do not delay one another. The button state is also read in the same loop. With this method several independent tasks appear to run simultaneously on a single processor. When the timestamp value wraps around after a long period, the difference calculation can overflow; computing the difference by subtraction avoids this problem. The circuit is a simple example of the task-scheduling model used in real embedded systems.
Expected result
The red LED blinks quickly and the blue LED slowly; button presses are detected without delay.
Tips and common mistakes
- Using a delay command synchronises the LEDs and makes you miss the button.
- Each task must have its own time record; a shared record causes conflicts.
- If the interval is too short, the LED is invisible to the eye.
- Always compute the time difference by subtraction.
Try it yourself
- Light the two LEDs at different intervals.
- Add a third task when the button is pressed.
- Switch to a delay command and observe the difference in behaviour.
What you learn in this circuit
- Distinguishes non-blocking timing from the delay command.
- Runs several independent tasks in one loop.
- Checks intervals using timestamp differences.
- Prevents timer overflow through calculation.
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.