title: Blink LED for first 5 seconds, stay solid for last 5 seconds on button press (Arduino)
body: <p>So this is probably not that hard, but I'm a bit stumped. I have a button that is the "Take picture" button in a larger control panel. Right now the LED flips on for 10 seconds then flips off. I'd like it to blink for the first 5 seconds, then stay solid for the last 5 seconds. Not sure how to go about that, I've tried some guessing, but no go. Here's what I have so far, its currently long and ugly:</p>
  
  <pre><code>// take a picture button
  
  
  const int shoot_pin = 5;
  const int shoot_led = 13; 
  
  int shoot_state = 0;
  int last_shoot_state = 0;
  
  
  long shoot_timer;
  long lastDebounceTime = 0;  // the last time the output pin was toggled
  long debounceDelay = 10;    // the debounce time; increase if the output flickers
  
  
  void setup(){
     Serial.begin(9600);
     pinMode(shoot_pin, INPUT);
     pinMode(shoot_led, OUTPUT);
  
  }
  
  void loop() {
    int shoot_reading = digitalRead(shoot_pin);
  
    if (shoot_reading != last_shoot_state) { lastDebounceTime = millis(); } 
  
    if ((millis() - lastDebounceTime) &gt; debounceDelay) {
  
      if (shoot_reading != shoot_state) {
        shoot_state = shoot_reading;
  
        if (shoot_state == HIGH) {
            digitalWrite(shoot_led, HIGH);
            shoot_timer = millis();
            Serial.println("Counting down...5 seconds"); // for tracking
            delay(5000);
            Serial.println("Shooting Picture"); // for tracking - eventually will be a keypress
  
        } // end of high
  
      } // end of reading
  
    }// end of that giant nested debaounce
  
    last_shoot_state = shoot_reading;
  
    // right now just stays lit for 10 seconds
    if (millis() - shoot_timer &gt;= 10000){ digitalWrite(shoot_led, LOW);}
  
  } // end of loop
  </code></pre>