Compare the new sample in a high sampling rate datalogger I am using sdFat library the analog bin logger example, 

Github: SdFat/SdFat/examples/AnalogBinLogger/


The program is working fine and every thing but the thing is, this high speed datalogger uses interrupts and timers to make the ADC work at a pre-determined sampling frequency and it DOES NOT use the normal analogRead ()

What I want is, when the input of some analog pin is bellow a pre-determined value, I want to write HIGH or LOW to some digital pin, 
my question is, how can I compare the new sample in the analog bin logger example as I simply want to compare the new sample as in:

if ( analogRead() &lt; 256 ) {// do something}


knowing that there is no analogRead() in the program because it uses timers and interrupts.
In the function

ISR(ADC_vect) {


the variable d contains the current sample:

  // Read ADC data.
#if RECORD_EIGHT_BITS
  uint8_t d = ADCH;
#else  // RECORD_EIGHT_BITS
  // This will access ADCL first.
  uint16_t d = ADC;
#endif  // RECORD_EIGHT_BITS


So you can just "do something" depending on what is in d.  Of course, since this is a timer interrupt you have limited time to do anything, so you need to make sure that whatever you do is fast and efficient - so really you want to be using direct port access instead of digitalWrite().