CCNAP

TPL-02Templates/LED Bar Graph

LED Bar Graph

Knight Rider chaser on a 10-segment LED bar graph. A single lit dot sweeps forward and backward using pins 2–11.

Open in Playgroundbeginner · LED · bar graph · digital output · animation
beginner

FIG. 1LED Bar Graph · circuitTPL-02

02Sketch

sketch.inoArduino C++
24 lines
// LED Bar Graph — Knight Rider chaser
const int NUM_LEDS = 10;
const int PINS[NUM_LEDS] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};

void setup() {
  for (int i = 0; i < NUM_LEDS; i++) {
    pinMode(PINS[i], OUTPUT);
  }
}

void loop() {
  // Sweep forward
  for (int i = 0; i < NUM_LEDS; i++) {
    digitalWrite(PINS[i], HIGH);
    delay(60);
    digitalWrite(PINS[i], LOW);
  }
  // Sweep backward
  for (int i = NUM_LEDS - 2; i > 0; i--) {
    digitalWrite(PINS[i], HIGH);
    delay(60);
    digitalWrite(PINS[i], LOW);
  }
}

03Components

  • 01Arduino Uno
  • 02LED Bar Graph (wokwi-led-bar-graph)
  • 03Resistor 220Ω × 10

04Wiring

Component pinArduino pin
Anodes A1–A10Pins 2–11 (each via 220 Ω resistor)
Cathodes C1–C10 (all tied together)GND

All templates

Ready when you are

Have a circuit in mind?

No hardware, no installs — a browser is enough.