   }
 
   // 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);

Bounce modeButton;

// config
int staticBpm = 70; // From http://ecg.utah.edu/img/items/Normal%2012_Lead%20ECG.jpg
byte beat[]  = {3,2,2,2,2,3,4,3,2,1,0,15,2,2,3,4,6,8,5,3,3,3};
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 movesPerBeat = 8;
int minMagnitude = 80;
int maxMagnitude = 150;
int minBrightness = 180; // from 0-255
int maxBrightness = 255; // from 0-255
int beatMaxIntensity = max(beat);
int minHue = 160; // hue value under low motion
int maxHue = 255; // hue value under high motion
int gainRatePerBeat = 200; // value change towards new target value (percent*100 per beat, e.g 200 = 20%)
int decayRatePerBeat = 3  ; // percent change towards new target per beat
int sampleSize = 8; // smooth out accelerometer readings
int samplePerBeat = 2;

// state
int bpm = staticBpm;

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