     }
   }
 
-    Serial.print("Delta: "); Serial.print(delta); Serial.print("    ");
+//    Serial.print("Delta: "); Serial.print(delta); Serial.print("    ");
 
   return currentRPM + delta;
 }

  unsigned long delta = micros() - lastUpdate;
  lastUpdate = micros();
  engineSpeed = calculate_RPM(engineSpeed, get_throttle_position(), delta);
  
  Serial.print("Engine Speed: ");
  Serial.println(engineSpeed);

  #ifdef WHEELSPEED_ENABLE
    //Wheel Speed Calculations
    float wheelSpeed;
    //Assume the Rekluse clutch works properly
    set_curr_gear();
    if(engineSpeed >= 4000) {
      wheelSpeed = engineSpeed * GEAR_RATIOS[currentGear - 1] * FINAL_DRIVE * WHEEL_CIRCUMFERENCE * 3.6; //Km/h
    } else {
      wheelSpeed = 0;
    }
  
    float wheelOutputValue = (float)wheelSpeed * 255.0 / 50000.0; //Scaled between 0 and 140 km/h
    analogWrite(wheelSpeedLeftPin, wheelOutputValue);
    analogWrite(wheelSpeedRightPin, wheelOutputValue);
  #endif
  //doPwmThrottle();
  delayMicroseconds(500);

  currentGear = gear;
  Serial.print("current gear:");
  Serial.print(currentGear);
  Serial.print("    "); 
//  Serial.print("G");
//  Serial.println(currentGear);  
}

float get_throttle_position() {
  int analogReading = analogRead(throttlePositionPin); //Pin reads up to 5V, but max we supply is 3.3V
//  Serial.print("throttle position:");
//  Serial.print(analogReading);
//  Serial.print("    ");
  return (float)analogReading * 100.0 / 675.0; //675/1024 is approximately 3.3/5.0
}

