VIN Technologies › Labs › Microcontroller Lab

LED chaser (for loop over pins)

Microcontroller Lab · free online experiment, runs in your browser with no install or sign-up.

Open this experiment in the circuit simulator

Objective

Light four LEDs one after another with a for loop over pins 2–5.

Procedure

  1. Press Start Simulation and watch the LEDs.
  2. Change delay(200) to delay(50) for a faster chaser.
  3. Add a fifth LED on pin 6.

Theory

A for loop writes HIGH to a pin, waits 200 ms and writes LOW before moving to the next pin. Each LED has its own 220 Ω resistor: I ≈ (5 V − 1.9 V − 0.6 V drop in the pin)/220 Ω ≈ 11 mA.

Questions to answer

  1. How would you make the light bounce back and forth?

Components used

Arduino UNO R3 (clone, SMD), Breadboard 400 points, 4 × LED 5mm Red, 4 × Resistor 220 ohm 1/4W

About the model

Breadboard contacts are ideal (no contact resistance or capacitance). Arduino-style C/C++ subset interpreter (not AVR machine code): no interrupts or libraries, int is 16-bit, only delay() advances time, pin modes are fixed after setup(). Outputs are 5 V behind 25 Ω.

Open this experiment in the circuit simulator

More Microcontroller Lab experiments