 int j = 0;
 float runningSum = 0;
 float oldAverage;
+int servoVal = 90;
 bool int_flag = false;
 
 void setup() {

  oldAverage = getAverage();
  
  xy.attach(3); // pro mini pwm pin
  xy.write(0); // Start at a well-defined value

  MsTimer2::set(100, a);
  MsTimer2::start();


void loop() {
  if (int_flag) {
    j %= 10;
    runningSum -= entries[j];
    entries[j] = readGyro();
    runningSum += entries[j];
    float newAverage = getAverage();
    //Serial.println(newAverage - oldAverage, 2); // Print drift in 100 ms
    servoVal += newAverage - oldAverage;
    rotate(servoVal);
    oldAverage = newAverage;
    j++;
    int_flag = false;
