Schematic
The code:
int ledPins[] = {13, 12, 11, 10, 9, 8, 7, 6,5,4};
int numLEDs = sizeof(ledPins) / sizeof(ledPins[0]);
int delayTime = 80; // Waktu tunda dalam milidetik
void setup() {
for (int i = 0; i < numLEDs; i++) {
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
for (int i = 0; i < numLEDs; i++) {
digitalWrite(ledPins[i], HIGH);
delay(delayTime);
digitalWrite(ledPins[i], LOW);
}
for (int i = numLEDs - 1; i >= 0; i--) {
digitalWrite(ledPins[i], HIGH);
delay(delayTime);
digitalWrite(ledPins[i], LOW);
}
}
No comments:
Post a Comment