   pinMode(PIN_MUX_S2, OUTPUT);
   pinMode(PIN_MUX_S3, OUTPUT);
   pinMode(PIN_MUX_AN, INPUT);
-  calibrateSensor();
+  //calibrateSensor();
   
 }
 
 void loop() {
   digitalWrite(PIN_MUX_ENABLE, HIGH);
+  digitalWrite(PIN_MUX_S0, HIGH);
   readValues();
-  Serial.print("Position = ");
   Serial.print(getPosition());
   Serial.println();
   delay(100);

#define PIN_MUX_S0 6
#define PIN_MUX_S1 12
#define PIN_MUX_S2 7
#define PIN_MUX_S3 4
#define PIN_MUX_AN 5
#define PIN_MUX_ENABLE 16
int values[16];
int SENSOR_MIN;
int SENSOR_MAX;
static int S[] = {PIN_MUX_S0, PIN_MUX_S1, PIN_MUX_S2, PIN_MUX_S3};
  
void readValues(){
    for(uint8_t i = 8; i < 16; i++){
      for(int n = 0; n < 4; n++){
        digitalWrite(S[n], i & (0x1 << n));
      }
      values[i] = analogRead(PIN_MUX_AN);
    }
  }

float getPosition(){
  float weighted_sum = 0;
  float sum = 0;
  for(int i = ini; i < fim; i++){
    float value = (getValue(i) - 0.0) * (-1.0) / (SENSOR_MAX - SENSOR_MIN) + 1.0;
    value = fmin(fmax(0.0, value), 1.0);
    Serial.print(i);
    Serial.print(" : ");
    Serial.print(value);
    Serial.print(" ");
    weighted_sum = weighted_sum + value  * (i -7);
    sum = sum + value;
  }
  float position = ((weighted_sum / sum) - 4.5) / 3.5;
