So basically I copy and paste the BlinkWithoutDelay 18 times total, and then have 18 different delay time setups?
Yes that is one way. Remember to change the variable names for each LED.
how COULD I go about doing the loop and array thing
Right but I want you to fully understand this and explain it to the class, also do not pretend it is all your own work.
Might have the odd bug as I have not tested it, but it compiles:-
long nextFlash[18];
int interval[] = { 100, 200, 300, 400, 500, 600, 700, 800,
900, 1000, 1100, 1200, 1300, 1400, 1500, 1600,
1700, 1800}; // flash intervals
int ledPin[] = { 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20}; // LED pins to use.
int ledState[18];
void setup(){
for(int i = 0; i<18; i++){
pinMode(ledPin[i],OUTPUT);
ledState[i] = LOW;
digitalWrite(ledPin[i], LOW); // all LEDs off
nextFlash[i] = millis()+ interval[i];
}
}
void loop(){
for(int i = 0; i<18; i++){
if(millis() > nextFlash[i]){
if(ledState[i] == LOW) ledState[i] = HIGH; else ledState[i] = LOW;
digitalWrite(ledPin[i],ledState[i]);
nextFlash[i] = millis()+ interval[i];
} }
}