LED Sign blinking, chaseing, BEETLEJUICE

vinceherman:
Is this the sign you are trying to simulate?
Beetlejuice on Vimeo

Yes. I have attached a picture (hopefully) of my sign.

MORGANS you are a genius! Thank you so much for taking the time to write all that out! Your code compiled on the second try and worked like a charm! Your notes were fabulous and allowed me to really understand what was going on. I had no idea you could write a loop code like you did. Made that super easy.
I ended up making the lights chase and then added another section that allows a solenoid to blink the lights behind the sign itself. I like your idea of adding fading and flickering. I honestly have a ton of stuff to build and might not have time to add that to the code. I will post of a video once I get this thing all soldered together.

Again, this is a great community. I like to think I am intelligent, but really struggle with coding.

If you want to see some of the stuff I am making there are a ton of pics here

//Timing for all the lights
int arrowInterval = 120; //milliseconds - interval between changes on the arrow section
int outsideInterval = 500; //milliseconds - interval between changes on the arrow section
int signOnTime = 1200;   //milliseconds - time the outside lights are on for the flash
int signOffTime = 500; //milliseconds - time the outside lights are OFF for the flash



int arrowArray[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};  // arrow lights
int arrowLen = 11;       //the number of lights in the array above
int arrowCount = 0;      //keeps the state of the arrow lights (which LED is currently on)

int outsideArray[] = {28, 30, 32};   //outside sign lights
int outsideLen = 3;       //the number of lights in the array above
int outsideCount = 0;      //keeps the state of the arrow lights (which LED is currently on)


int signSwitch = 22;    //main sign light
//int signInterval = 300; //milliseconds - interval between changes on the sign
int signState = LOW;   //blink the outside lights variable




unsigned long arrowMillis = 0;        
unsigned long outsideMillis = 0;        
unsigned long signMillis = 0;



void doArrow(unsigned long currentMillis) {
  //animating the arrow is easy - only one output pin is on at one time (you may connect some pins to more than one light)
  if(currentMillis - arrowMillis >= arrowInterval) {
    arrowMillis += arrowInterval; 

    digitalWrite(arrowArray[arrowCount], LOW);  //turn off the light that is currently on
    arrowCount++;                               //advance the counter
    if(arrowCount >= arrowLen) arrowCount = 0;  //if we went off the end, start at the beginning
    digitalWrite(arrowArray[arrowCount], HIGH); //turn on the current light
  }  
}



void doOutside(unsigned long currentMillis) {
  
  if(currentMillis - outsideMillis >= outsideInterval) {
    outsideMillis += outsideInterval; 

    digitalWrite(outsideArray[outsideCount], LOW);  //turn off the light that is currently on
    outsideCount++;                               //advance the counter
    if(outsideCount >= outsideLen) outsideCount = 0;  //if we went off the end, start at the beginning
    digitalWrite(outsideArray[outsideCount], HIGH); //turn on the current light
  }  
}

void signAllChange(int LEDState) {
  // set the LED with the ledState of the variable:
  for (int count = 0; count < outsideLen; count++) {
    digitalWrite(signSwitch, LEDState);
  }
}
  
 void doSignSwitch(unsigned long currentMillis) {
  //flash the sign lights
  if(signState == LOW) {
    if(currentMillis - signMillis >= signOffTime) {
      signMillis += signOffTime;
      signState = HIGH;
      signAllChange(signState);
    }
  } else { //sign lights are on
    if(currentMillis - signMillis >= signOnTime) {
      signMillis += signOnTime;
      signState = LOW;
      signAllChange(signState);
    }    
}}

void setup() {
  // we make all the declarations at once
  for (int count = 0; count < arrowLen; count++) {
    pinMode(arrowArray[count], OUTPUT);
  }
  for (int count = 0; count < outsideLen; count++) {
    pinMode(outsideArray[count], OUTPUT);
  }
  pinMode(signSwitch, OUTPUT);
}


void loop() {
  unsigned long currentMillis = millis();

  doArrow(currentMillis);

  doOutside(currentMillis);

  doSignSwitch(currentMillis);

  //since neither of the above functions are "blocking", which means they only take a few nanoseconds or microseconds to run each time
  //then we can do more work here
  //add some more functions!
}