The "Knight Rider" effect — a glowing dot bouncing along a row of LEDs — looks dynamic, but it's the simplest control loop you can write. One index variable points at which LED is on. Increment the index, repeat. The hardware is doing nothing fancy; the illusion of motion is entirely in your eye.
Indexes are how computers talk to pins
You probably already think of LEDs as individual pins: digitalWrite(4, HIGH). But once you have more than two of them, you want to refer to them with a single name. An array gives you exactly that: int leds[] = {2, 3, 4, 5, 6, 7};. Now leds[i] is "the pin at position i" — and i can come from anywhere: a counter, a sensor, a button.
The scanner loop is the smallest example: set leds[i] HIGH, set all the others LOW, wait, then i = (i + 1) % 6. Six lines of code, six pins. The same pattern scales to a 64-element WS2812 strip without a single change in shape.
Persistence of vision does the work
Your eye holds an image for about 50–100 milliseconds. If you cycle through six LEDs at 80 ms each, the impression is of one lit dot moving smoothly across — not six LEDs blinking in sequence. Drop the delay to 16 ms and the lit position becomes a smear; raise it to 300 ms and the illusion breaks and you see discrete steps. The timing is the whole effect.