 
   fade(PULSE_MAX_VAL, pulse_duration / 2);
 }
+
+// Called when the button is both pressed and released.
+ISR(PCINT0_vect){
+  if (!(PINB & (1 << PINB6))) {
+    buttonDebounced = false;
+
+    // Configure and start timer4 interrupt.
+    TCCR4B = 0x0F; // Slowest prescaler
+    TCCR4D = _BV(WGM41) | _BV(WGM40);  // Fast PWM mode
+    OCR4C = 0x10;        // some random percentage of the clock
+    TCNT4 = 0;  // Reset the counter
+    TIMSK4 = _BV(TOV4);  // turn on the interrupt
+  } else {
+    TIMSK4 = 0;  // turn off the interrupt
+  }
+}
+
+// This is called every xx ms while the button is being held down; it counts down then displays a
+// visual cue and changes the pattern.
+ISR(TIMER4_OVF_vect) {
+  // If the user is still holding down the button after the first cycle, they were serious about it.
+  if (buttonDebounced == false) {
+    buttonDebounced = true;
+
+    switch (brightness) {
+      case BRIGHTNESS_MIN:
+        brightness = BRIGHTNESS_MED;
+        break;
+      case BRIGHTNESS_MED:
+        brightness = BRIGHTNESS_MAX;
+        break;
+      case BRIGHTNESS_MAX:
+        brightness = BRIGHTNESS_MIN;
+        break;
+    }
+    FastLED.setBrightness(brightness);
+  }
+}

#define CHANGE_MIN_VAL 64
#define CHANGE_DURATION 800

// state
CRGB leds[NUM_LEDS];
bool initialized;
uint8_t hue;
uint8_t val;
bool pulse;
long pulse_duration;



void fade(uint8_t new_val, long duration) {
  if (val == new_val) {
    return;
  }
  

#define LED_CORRECTION TypicalSMD5050

#define DATA_PIN 13
#define BUTTON_IN 10
#define ANALOG_INPUT A9
#define EXTRA_PIN_A 7
#define EXTRA_PIN_B 11

// visuals
#define PULSE_MAX_VAL 255
