กลับไปหน้ารวมไฟล์
led-pattern-generator-en.md

Light Choreography: LED Patterns

The LED Pattern Generator takes the single blinking LED and multiplies it by ten. It introduces you to complex for loops, arrays, and bit-shifting tricks.

button_led_basic_interaction_1772681969235.png

Arrays in Action

If you have 8 LEDs, you don't write digitalWrite(3, HIGH); digitalWrite(4, HIGH);.

  1. The Array: You store all the pin numbers in an array: int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9};.
  2. The Chaser Loop: You write a for (int i=0; i<8; i++) loop that runs through the array, turning each LED on for 50 milliseconds, then turning it off, before moving to the next. This creates the classic "Knight Rider" sweep effect.

Key Hardware

  • Arduino Uno/Nano: The sequence generator.
  • LEDs (x8 or x10): You can use single colors or a gradient of colors.
  • 220-ohm Resistors: One for every single LED to prevent burning.
  • Breadboard: A large breadboard is required for this many connections.

Building extensive LED patterns is the prerequisite skill for managing complex displays like the massive LED cubes or LED matrices.

ข้อมูล Frontmatter ดั้งเดิม

title: "LED Pattern Generator"
description: "Dazzling displays! Program mesmerizing chaser light sequences across a massive array of LEDs."
category: "Basic Electronics"
difficulty: "Easy"