 
     //adc->setReference(ADC_REFERENCE::REF_1V2, ADC_NUM::ADC_1);
 
-    // always call the compare functions after changing the resolution!
-    //adc->enableCompare(1.0/3.3*adc->getMaxValue(ADC_NUM::ADC_1), 0, ADC_NUM::ADC_1); // measurement will be ready if value < 1.0V
-    //adc->enableCompareRange(1.0*adc->getMaxValue(ADC_NUM::ADC_1)/3.3, 2.0*adc->getMaxValue(ADC_NUM::ADC_1)/3.3, 0, 1, ADC_NUM::ADC_1); // ready if value lies out of [1.0,2.0] V
-
 
     // If you enable interrupts, note that the isr will read the result, so that isComplete() will return false (most of the time)
     //adc->enableInterrupts(ADC_NUM::ADC_1);
 
     #endif
 
-    delay(500);
-}
-
-int value = 0;
-int pin=0;
-
-void test_pull(bool pullup) {
-    uint8_t mode = pullup ? INPUT_PULLUP : INPUT_PULLDOWN;
-
-    for (int i=0;i<DIG_PINS;i++) {
-        pinMode(adc_pins[i], mode);
-        value = adc->analogRead(adc_pins_dig[i]);
-        if (value < 3.2) {
-            Serial.print("A"); Serial.print(i); Serial.print(": ");
-            Serial.print("FAILED "); Serial.print(pullup ? "INPUT_PULLUP" : "INPUT_PULLDOWN"); Serial.println(". ");
-        }
-    }
-}
+    delay(2000);
+
+    ////// START TESTS /////////////
+
+    bool pullup_test = test_pullup_down(true);
+    Serial.print("PULLUP TEST "); Serial.println(pullup_test ? "PASS" : "FAIL");
+    bool pulldown_test = test_pullup_down(false);
+    Serial.print("PULLDOWN TEST "); Serial.println(pulldown_test ? "PASS" : "FAIL");
+    bool compare_test = test_compare();
+    Serial.print("COMPARE TEST "); Serial.println(compare_test ? "PASS" : "FAIL");
+    bool compare_range_test = test_compare_range();
+    Serial.print("COMPARE RANGE TEST "); Serial.println(compare_range_test ? "PASS" : "FAIL");
+
+    test_averages();
+}
+
+
 
 
 void loop() {
-
-    test_pull(true);
-    test_pull(false);
-
-
     // Print errors, if any.
     adc->printError();
     adc->resetError();
 
 
-    //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN));
+    digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN));
 
     delay(500);
 

uint8_t adc_pins_diff[] = {A10, A11};
#endif // defined

void setup() {

    pinMode(LED_BUILTIN, OUTPUT);

    // it can be any of the ADC_MED_SPEED enum: VERY_LOW_SPEED, LOW_SPEED, MED_SPEED, HIGH_SPEED or VERY_HIGH_SPEED
    adc->setSamplingSpeed(ADC_SAMPLING_SPEED::VERY_LOW_SPEED); // change the sampling speed

    // If you enable interrupts, notice that the isr will read the result, so that isComplete() will return false (most of the time)
    //adc->enableInterrupts(ADC_NUM::ADC_0);

