   }
 
   // Slowly decay max target
+  targetMagnitude = targetMagnitude - decayRatePerBeat;
   targetMagnitude = constrain(
-    targetMagnitude - (targetMagnitude*(decayRatePerBeat/100)), 
+    targetMagnitude,
     minMagnitude, 
     maxMagnitude
   );
-//
+
 //  Serial.print(magnitudeDiff);
 //  Serial.print("\t");
 //  Serial.print(targetMagnitude);

  if(adjustedMagnitude <= targetMagnitude) {
    adjustedMagnitude = constrain(
      constrain(
        targetMagnitude + (targetMagnitude*(gainRatePerBeat/100)), 
        minMagnitude,
        maxMagnitude
      ),

Bounce modeButton;

// config
int staticBpm = 60; // From http://ecg.utah.edu/img/items/Normal%2012_Lead%20ECG.jpg
int maxBpm = 180; // avoids the system going crazy
byte beat[]  = {2,2,2,2,3,4,3,2,1,0,12,2,2,3,4,6,8,5,3,3,3,3};
byte beatLength = 22;
int beatMaxIntensity = 12; // max value in beat array
int movesPerBeat = 4;
int minMagnitude = 0;
int maxMagnitude = 50; // max difference between two magnitude measurements from accelerometer at which we show maxHue
int minBrightness = 150; // from 0-255
int maxBrightness = 200; // from 0-255
int minHue = 160; // hue value under low motion, as defined through minMagnitude (from 0-255)
int maxHue = 255; // hue value under high motion, as defined through maxMagnitude (from 0-255)
int gainRatePerBeat = 6; // change towards new target magnitude
int decayRatePerBeat = 2; // move back towards minMagnitude
int sampleSize = 8; // smooth out accelerometer readings
int samplePerBeat = 1;

// state
int bpm = staticBpm;
