   }
   else if (selection == 0)
   {
-    if (verificationSetpointHigh(sensorValue,setpointHigh)==1)
+    if (verificationSetpointHigh(sensorValue,setpointHigh,maxControllerVoltage, limitSetpointHighInAnalog)==1)
     {
       intensityInPercent = 0;
     }
-    else if (verificationSetpointLow(sensorValue,setpointLow)==1)
+    else if (verificationSetpointLow(sensorValue,setpointLow,maxControllerVoltage, limitSetpointLowInAnalog)==1)
     {
       intensityInPercent = 100;
     }

///////FUNCTION/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void displaySerialInformation()                                                              // Read the global declaration in order to display information on the serial monitor // 0 for all value
{        
  int k;  
  char myChar;                                                     

  }
}

void seriesRegulator(int & sensorValue, float maxControllerVoltage, char selection, float setpointHigh, float setpointLow, float & Vin, int limitSetpointHighInAnalog, int limitSetpointLowInAnalog)                            // The function that does the regulation
{
  char i;
  for (i=0; i<11; i++)
  {
    delay(50);
    sensorValue = analogRead(analogInPinV);
    Vin = getVin(sensorValue, maxControllerVoltage);   
    controlMosfet(selection, maxControllerVoltage, sensorValue, setpointHigh, setpointLow, limitSetpointHighInAnalog, limitSetpointLowInAnalog);
    //CheckButtonA();
  } 
}

void PWMwrite(int intensity, int outputPin, int limitSetpointHighInAnalog, int limitSetpointLowInAnalog)       // Generate the PWM square wave with the right duty cycle
{  
  int mappedIntensity;
  mappedIntensity = map(intensity,limitSetpointLowInAnalog,limitSetpointHighInAnalog, 0, 255);
  analogWrite(outputPin, mappedIntensity);
}

void controlShuntPWM(float maxControllerVoltage, int sensorValue, float setpointHigh, float setpointLow, int limitSetpointHighInAnalog, int limitSetpointLowInAnalog)                        
{
  if(verificationSetpointHigh(sensorValue,setpointHigh,maxControllerVoltage, limitSetpointHighInAnalog)==1)     //Voltage higher than setpointHigh
  {
    digitalWrite(overchargeIndicatorLed, HIGH);                                      // Turn on the led // Overcharged
  }
  else if (verificationSetpointLow(sensorValue,setpointLow,maxControllerVoltage, limitSetpointLowInAnalog)==1) //Voltage lower than setpointLow
  {
    digitalWrite(overchargeIndicatorLed, LOW);                                       // Turn off the led // Not overcharged
  }
  else
  {
    PWMwrite(sensorValue, overchargeIndicatorLed, limitSetpointHighInAnalog, limitSetpointLowInAnalog);                                   // Hysteresis
  }
}

void controlShuntNoPWM(float maxControllerVoltage, int sensorValue, float setpointHigh, float setpointLow, int limitSetpointHighInAnalog, int limitSetpointLowInAnalog)
{
  if(verificationSetpointHigh(sensorValue,setpointHigh,maxControllerVoltage, limitSetpointHighInAnalog)==1)     //Voltage higher than setpointHigh
  {
    digitalWrite(overchargeIndicatorLed, HIGH);                                      // Turn on the led // Overcharged
  }
  else if (verificationSetpointLow(sensorValue,setpointLow,maxControllerVoltage, limitSetpointLowInAnalog)==1) //Voltage lower than setpointLow
  {
    digitalWrite(overchargeIndicatorLed, LOW);                                       // Turn off the led // Not overcharged
  }
  else
  {
                                                                                     // Hysteresis
  }
}

void controlMosfet(char selection, float maxControllerVoltage, int sensorValue, float setpointHigh, float setpointLow, int limitSetpointHighInAnalog, int limitSetpointLowInAnalog)                                            // Selection of the control mode
{
  if (selection == 0)
  {
    controlSerieNoPWM(maxControllerVoltage, sensorValue, setpointHigh, setpointLow, limitSetpointHighInAnalog, limitSetpointLowInAnalog); 
  }
  else if (selection == 1)
  {
    controlSeriePWM(maxControllerVoltage, sensorValue, setpointHigh, setpointLow, limitSetpointHighInAnalog, limitSetpointLowInAnalog); 
  }
  else if (selection == 2)
  {
    controlShuntNoPWM(maxControllerVoltage, sensorValue, setpointHigh, setpointLow, limitSetpointHighInAnalog, limitSetpointLowInAnalog); 
  }
  else if (selection == 3)
  {
    controlShuntPWM(maxControllerVoltage, sensorValue, setpointHigh, setpointLow, limitSetpointHighInAnalog, limitSetpointLowInAnalog); 
  }
}

char getIntensityInPercent(char selection, int sensorValue, float setpointHigh, float setpointLow, float maxControllerVoltage, int limitSetpointHighInAnalog, int limitSetpointLowInAnalog)                                    // Turn sensorValue into a percentage depending on the value of "selection"
{  
  int intensityInPercent;
  if (selection == 2)
  {
    if (verificationSetpointHigh(sensorValue,setpointHigh,maxControllerVoltage, limitSetpointHighInAnalog) == 1)
    {
      intensityInPercent = 100; 
    }
    else if (verificationSetpointLow(sensorValue,setpointLow,maxControllerVoltage, limitSetpointLowInAnalog) == 1)
    {
      intensityInPercent = 0;
    }
