
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 is it for?
In this project, four LEDs are connected to four separate digital output pins, each with a 220-ohm series resistor in front of it. The cathodes meet on a common ground line. The software lights the LEDs one at a time, first from left to right and then from right to left, applying a short delay at each step. This produces a light that chases back and forth. This effect teaches arrays, loop structures and timed control of output pins together. The same sequencing logic underlies indicator panels, stage lights and warning systems. The hardware side of the circuit is simple; the challenge is setting up the sequence correctly in software.
Parts list
The following components are used to build this project:
- Arduino Uno — Controls the four outputs with timing.
- 220Ω Resistor — One separate current limiter for each LED (×4).
- Red LED — The first and fourth indicators in the sequence.
- Yellow LED — The second indicator in the sequence.
- Green LED — The third indicator in the sequence.
- Ground — Common return path for the four LEDs.
Step-by-step build
- Place the board and arrange the four LEDs in a vertical row.Keep the ordering the same as the array you will use in the code.
- Connect a 220-ohm resistor to the anode of each LED.The free end of the resistor will go to an output pin.
- Connect the resistors to four separate output pins.Store the pin numbers in an array.
- Connect the cathodes of the four LEDs to the common ground rail.A single GND line is enough.
- Connect the ground rail to the board's GND pin.Without a common reference the LEDs do not turn off properly.
- Upload the code; the light chases forwards and backwards.The delay determines the chasing speed.
How it works
The code holds the output pins in an array and moves forward through the array, setting each pin HIGH briefly. The delay at the end of each step lets the human eye perceive the light separately. Reversing the array repeats the same sequence backwards, producing the chasing-light effect. In hardware, each LED is driven by its own 220-ohm resistor, which keeps the current safe even when several LEDs are on at once. The common-cathode connection gives all LEDs the same reference point and lets the circuit be expanded without complication.
The four LEDs and four resistors are arranged in vertical rows. Each LED's cathode goes to the common ground rail on the right, and its anode to a separate output pin through its own resistor. The ground rail returns to the board with a single GND wire.
What you will learn
- Controls multiple outputs using arrays and loops.
- Uses delay to create a timed sequence.
- Explains the advantage of a common-cathode connection.
- Applies the chasing-light logic in reverse order.
Tips
- If the light does not chase, compare the pin order in the array with the LED layout.
- If the delay is too short, the LEDs appear to be on together.
- If an LED stays on continuously, the line that sets that pin LOW may be missing.
Try it yourself
- Observe the light chasing forwards and backwards.
- Compare the chasing speed by changing the delay.
- Add a fifth LED to the array and extend the sequence.
Getting the parts
If you want to build this project in real life, you can get the parts from hobidevre.com. For more circuit ideas, visit the hobidevre.com blog.
Frequently asked questions
What does this circuit do?
Create a chasing-light effect by lighting four LEDs in turn forwards and backwards.
How does the circuit work?
The code holds the output pins in an array and moves forward through the array, setting each pin HIGH briefly. The delay at the end of each step lets the human eye perceive the light separately. Reversing the array repeats the same sequence backwards, producing the chasing-light effect. In hardware, each LED is driven by its own 220-ohm resistor, which keeps the current safe even when several LEDs are on at once. The common-cathode connection gives all LEDs the same reference point and lets the circuit be expanded without complication.
What is the expected result?
The LEDs light up and go out in forward and reverse order, creating a chasing-light effect.