   }
   OldTime = millis();
   old_degrees = new_degrees;
-}  
-   //delay(10);
-  //for serial debugging, uncomment the next two lines.
-  //Serial.println(finalReading);
-  //delay(100);
 }
-    
+}
+

  for(int j = 0; j < NUM_LED; j++){  //write all LEDs low and stim pin low

    digitalWrite(leds[j], LOW);
    digitalWrite(StimPin, LOW); 
  }
  Serial.println(finalReading);
  //Serial.print("\t");
  finalReading = constrain(finalReading, 0, MAX);
  litLeds = map(finalReading, 0, MAX, 0, NUM_LED);
  //Serial.println(litLeds);
  
  for(int k = 0; k < litLeds; k++){
    digitalWrite(leds[k], HIGH); // This turns on the LEDS
    if (k >= Threshold){
      digitalWrite(StimPin, HIGH); // This turns on the TENS as a function of which LED is lit
    } 
  }
  
  new_degrees = map(finalReading, 0 ,MAX, 165, 0); //Translate the analog reading to degrees for the servo (from 165° to 0°).

if (millis() - OldTime > UpdateTime){

int reading[10];
int finalReading;
int StimPin = 3; // TENS Digital 3
int GripPin = 2; //Digital Out that controls Servo Motor Gripper Hand
int MAX = 0;
byte litLeds = 0;
byte multiplier = 1;
