     VREF::waitUntilStable();
 
     Serial.print("VREF value: ");
-    Serial.print(1.20/adc->adc1->analogRead(ADC_INTERNAL_SOURCE::VREF_OUT)*adc->getMaxValue(ADC_1), 5);
+    Serial.print(1.20/adc->analogRead(ADC_INTERNAL_SOURCE::VREF_OUT)*adc->getMaxValue(ADC_0), 5);
     Serial.println(" V.");
 
 
     Serial.print("Bandgap value: ");
-    Serial.print(3.3*adc->adc0->analogRead(ADC_INTERNAL_SOURCE::BANDGAP)/adc->getMaxValue(ADC_0), 5);
+    Serial.print(3.3*adc->analogRead(ADC_INTERNAL_SOURCE::BANDGAP)/adc->getMaxValue(ADC_0), 5);
     Serial.println(" V.");
 
     VREF::stop();
 }
 
 
-void loop() {}
+void loop() {
+}
 
-/* My output with a Teensy 3.6 connected to my laptop's USB.
+/*
+
+My output with a Teensy 3.6 connected to my laptop's USB.
 
 With a cheap multimeter I measured voltage_target = 3.29 V, the results are:
 
 niter,	a,	b,	midpoint,	diff (mV)
-0,		0,	63,	31,			27.84
-1,		31,	63,	47,			10.00
-2,		47,	63,	55,			1.15
-Optimal trim value: 55
-VREF value: 3.29115 V.
-Bandgap value: 1.00271 V.
+0,	    0,	63,	31,	    	38.62
+1,  	31,	63,	47,	    	17.06
+2,  	47,	63,	55,	    	6.81
+3,  	55,	63,	59,	    	1.42
+4,  	59,	63,	61,	    	-1.74
+5,  	59,	61,	60,	    	-0.50
+Optimal trim value: 60
+VREF value: 3.28977 V.
+Bandgap value: 1.00256 V.
 
 
 Using voltage_target = 3.3, which should be true:
 
 niter,	a,	b,	midpoint,	diff (mV)
-0,	    0,	63,	31,	    	26.83
-1,  	31,	63,	47,	    	0.00
-Optimal trim value: 47
-VREF value: 3.30000 V.
-Bandgap value: 1.00282 V.
+0,	    0,	63,	31,	    	28.48
+1,	    31,	63,	47,	    	7.20
+2,  	47,	63,	55,	    	-3.33
+3,	    47,	55,	51,	    	1.79
+4,	    51,	55,	53,	    	-0.84
+Optimal trim value: 53
+VREF value: 3.29874 V.
+Bandgap value: 1.00317 V.
+
+
+
+My output with a Teensy 3.0 connected to my laptop's USB.
+voltage_target = 3.22 V, the results are:
+
+niter,	a,	b,	midpoint,	diff (mV)
+0,  	0,	63,	31,		    37.34
+1,  	31,	63,	47,	    	16.56
+2,	    47,	63,	55,	    	5.54
+3,	    55,	63,	59,	    	-0.00
+Optimal trim value: 59
+VREF value: 3.21947 V.
+Bandgap value: 1.01978 V.
 
 
 */

//! change this value to your real input value, measured between AGND and 3.3V
float voltage_target = 3.3;

//! change the TOL (tolerance, minimum difference between voltage and target that matters)
//! to refine even more, but not to less than 0.001 or 0.002
const float TOL = 0.002;
// Maximum iterations of the algorithm, no need to change it.
const uint8_t MAX_ITER = 100;


float get_voltage(uint8_t trim) {
    VREF::trim(trim);
    VREF::waitUntilStable();
    return 1.20/adc->analogRead(ADC_INTERNAL_SOURCE::VREF_OUT)*(adc->getMaxValue(ADC_0));
}

// Simple bisection method to get the optimum trim value
// This method is not the bests for noisy functions...
// Electrical datasheet: "The Voltage Reference (VREF) is intended to supply an accurate voltage output
// that can be trimmed in 0.5 mV steps."
int8_t optimumTrimValue(float voltage_target) {
    // https://en.wikipedia.org/wiki/Bisection_method#Algorithm
    // INPUT: Function f, endpoint values a, b, tolerance TOL, maximum iterations NMAX
