This code controls 10 LEDs connected to pins 2 through 11 on an Arduino to simulate a "knight rider" light effect. It defines the pin numbers for the LEDs, sets them all as outputs during setup, and in the main loop uses for loops to light up the LEDs from left to right, turn them all off, then light them up from right to left in a repeating pattern.
This code controls 10 LEDs connected to pins 2 through 11 on an Arduino to simulate a "knight rider" light effect. It defines the pin numbers for the LEDs, sets them all as outputs during setup, and in the main loop uses for loops to light up the LEDs from left to right, turn them all off, then light them up from right to left in a repeating pattern.
This code controls 10 LEDs connected to pins 2 through 11 on an Arduino to simulate a "knight rider" light effect. It defines the pin numbers for the LEDs, sets them all as outputs during setup, and in the main loop uses for loops to light up the LEDs from left to right, turn them all off, then light them up from right to left in a repeating pattern.
void setup() { for (int i = 0; i < 10; i++) { pinMode(ledPins[i], OUTPUT); } }
void loop() {
for (int i = 0; i < 8; i++) {
digitalWrite(ledPins[i], HIGH); delay(30); } for (int i = 0; i <= 8; i++) { digitalWrite(ledPins[i], LOW); delay(30); } for (int i = 8; i >= 0; i--){ digitalWrite(ledPins[i], HIGH); delay(30); } for (int i = 8; i >= 0; i--){ digitalWrite(ledPins[i], LOW); delay(30); } }