If OR condition tracking

(>> means bit-shift-right!) - Never even thought of that. The IDE was happy so I just accepted it but thanks for pointing that out as I need to be more aware.

@PaulRB No the comma wasn't supposed to be there it was a typo. Well spotted tho, you all have keen eyes :slight_smile:

Still a huge amount to learn and I didn't want to come across as more experienced than I was so I tried to keep it simple, just didn't really give enough information for the help I needed. But I got there in the end.....

My objective is to test various gauges of nichrome/other wire to see how long and what current it takes to blow. This is a stripped-down function I have so far. The ADC takes about 65uS to complete each cycle and for now that's fine as I can play with that once my code runs as expected. Once the wire has blown (detected by trip_threshold) it should go into (if (pass_code > 0){) and output various information and depending on the pass_code eventually pass to other functions for more testing.

void runTest(){

    // Setup
    unsigned long timeout_t = 10000;  // 10,000uS - 10mS
    int a_pin = ADC_1, f_pin = debug_pin;
    int loop_count, low_count, high_count, trip_count = 0;
    int low_threshold = 250, high_threshold = 251, trip_threshold = 3;
    int buffer[160];  // buffer to store ADC readings
    int pass_code = 0;

    // Enable FET pin
    digitalWrite(f_pin, HIGH);

    // set start time
    unsigned long start_t = micros();

    // Start loop
    int x=0; while (x==0){

        // read ADC
        int adc_val = analogRead(a_pin);

        if (adc_val >= high_threshold) {high_count++; trip_count = 0;}
        if (adc_val <= low_threshold) {low_count++; trip_count++;}

        // save to buffer
        buffer[loop_count] = adc_val;

        if (micros() - start_t >= timeout_t) {
            pass_code = 1;
        } else if (trip_count >= trip_threshold) {
            pass_code = 2;
        } else if (high_count >= 15){
            pass_code = 3;
        } else if (low_count >= 15){
            pass_code = 4;
        }

        if (pass_code > 0){

            // Disable FET pin
            digitalWrite(f_pin, LOW);

            // Debug - Print out pass_code
            Serial.println(pass_code);

            // print buffer content
            for (int i=0; i<=loop_count; i++){
                Serial.printf("%d, ", buffer[i]);
                if (i==loop_count) {Serial.println("\n");}
            }

            // end while loop
            x=1;

        }        

        // increase loop count
        loop_count++;

    }
}

I will test what I have so far when I get home and see how it behaves. As always I really appreciate all the help and time you have all taken to help me.