int ledPin[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,}; // an array of pin numbers to which LEDs are attached
int pinCount = 11; // the number of pins (i.e. the length of the array)
int timer = 100; // The higher the number, the slower the timing.
int LedPins[] = { 17, 14, 15, 16 }; // an array of pin numbers to which LEDs are attached
//int pinCount = 4; // the number of pins (i.e. the length of the array)
void setup()
{
// the array elements are numbered from 0 to (pinCount - 1).
// use a for loop to initialize each pin as an output:
for (int analogpins = 0; analogpins < 4; analogpins++)
{
pinMode(LedPins[analogpins], OUTPUT);
}
{
// use a for loop to initialize each pin as an output:
for (int thisPin = 1; thisPin < 13; thisPin++)
{
pinMode(thisPin, OUTPUT);
}
}
}
void loop() {
// loop from the lowest pin to the highest:
for (int analogpins = 0; analogpins < 4; analogpins++)
{
// turn the pin on:
digitalWrite(LedPins[analogpins], HIGH);
delay(timer);
// turn the pin off:
digitalWrite(LedPins[analogpins], LOW);
}
// Speed up over 25 cycles, delays of 100 to 50
for (int timer = 120; timer > 20; timer -= 3)
{
Cycle(timer);
}
// Slow down over 25 cycles, delays of 50 to 100
for (int timer = 20; timer < 120; timer += 3)
{
Cycle(timer);
}
}
void Cycle(int pause)
{
// loop from the lowest pin to the highest:
for (int thisPin = 2; thisPin < 13; thisPin++)
{
// turn the pin on:
digitalWrite(thisPin, HIGH);
delay(timer);
// turn the pin off:
// digitalWrite(thisPin, LOW);
for (int analogpins = 0; analogpins < 4; analogpins++)
{
// turn the pin on:
digitalWrite(LedPins[analogpins], HIGH);
delay(timer);
// turn the pin off:
digitalWrite(LedPins[analogpins], LOW);
}
}
// loop from the highest pin to the lowest:
// for (int thisPin = 12; thisPin >= 2; thisPin--)
{
// turn the pin on:
// digitalWrite(thisPin, HIGH);
// delay(delayTime);
// turn the pin off:
//digitalWrite(thisPin, LOW);
//digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
}
}