 
     delay(ish);
 }
-

}

void blinkBackground(int times) {
  for (int x = 0; x < times; x++) {
      backgroundAllOff();
      delay(blinky);

      backgroundAllOn();
      delay(blinky);
  }

  delay(normal);
}

void blinkAllOnRandom() {
  int state[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

  for (int i = 0; i < sizeof(state); i++) {
    state[i] = 0;
  }

  int on = 0;

  while (on != sizeof(state)) {
    int value = random(0, sizeof(state));
    if (state[value]) {
      continue;
    }

    state[value] = 1;
    int pin = Lights[value];
    digitalWrite(pin, PATTERN_ON);
    on++;

    delay(minimal);
  }
}

void blinkBackgroundOnRandom() {
  int state[] = { 0, 0, 0, 0, 0, 0 };

  for (int i = 0; i < sizeof(state); i++) {
    state[i] = 0;
  }

  int on = 0;

  while (on != sizeof(state)) {
    int value = random(0, sizeof(state));
    if (state[value]) {
      continue;
    }

    state[value] = 1;
    int pin = background[value];
    digitalWrite(pin, PATTERN_ON);
    on++;

    delay(minimal);
  }
}

void blinkLettersOnRandom() {
	// from: int state[] = [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ];   
  int state[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };

  for (int i = 0; i < sizeof(state); i++) {
    state[i] = 0;
  }

  int on = 0;

  while (on != sizeof(state)) {
    int value = random(0, sizeof(state));
    if (state[value]) {
      continue;
    }

    state[value] = 1;
    int pin = letters[value];
    digitalWrite(pin, PATTERN_ON);
    on++;

    delay(minimal);
  }
}

void flickerPattern(int flickerLetters, int flickerBackground) {
  allOn();

  int max = 0;
  if (flickerLetters == 1) {
    max += 12;
  }
  if (flickerBackground == 1) {
    max += 8;
  }
  int pin = 0;
  for (int i = 0; i < random(5, max); i++) {
    if (i % random(1, max / 3) == 0) {
      if (flickerLetters == 1 && flickerBackground == 1) {
        pin = random(0, 2) == 0 ? letters[random(0, sizeof(letters))] : background[random(0, sizeof(background))];
      } else if (flickerBackground == 1) {
        pin = background[random(0, sizeof(background))];
      } else {
        pin = letters[random(0, sizeof(letters))];
      }
    }
    
    digitalWrite(pin, PATTERN_OFF);
    delay(random(minimal / 2, minimal));
    digitalWrite(pin, PATTERN_ON);
    delay(ish);
  }
}

// Randomness


void runTracer() {
    for (int i = 0; i < sizeof(background); i++) {
        digitalWrite(background[i], PATTERN_ON);
        delay(none);
    }
    for (int i = 0; i < sizeof(letters); i++) {
        digitalWrite(Lights[i], PATTERN_ON);
        delay(250);
        digitalWrite(Lights[i], PATTERN_OFF);
        delay(250);
    }
    for (int j = 0; j < 3; j++) {

        for (int i = 0; i < sizeof(letters); i++) {
            digitalWrite(Lights[i], PATTERN_ON);
            delay(none);
        }
        delay(250);
        for (int i = 0; i < sizeof(letters); i++) {
            digitalWrite(Lights[i], PATTERN_OFF);
            delay(none);
        }
        delay(250);

    }
    delay(250);
}

void runLetterPattern() {
    // if new patterns are added, add a new case statement, and bump up the max random value by one
    switch (random(0, 3)) {
    case 0: { lettersOnLeftToRight(); break; }
    case 1: { blinkLetters(random(5, 10)); break; }
    case 2: {  blinkLettersOnRandom(); break; }
    default: { break; }
    }
}

void runBackgroundPattern() {
    switch (random(0, 5)) {
    case 0: { classicBackground(); break; }
    case 1: { insideOutOutsideInBackground(); break; }
    case 2: { racingOnLeftToRightBackground(); break; }
    case 3: { blinkBackground(random(5, 10)); backgroundAllOn(); break; }
    case 4: { blinkBackgroundOnRandom(); break; }
    }
}

// Arduino loop
