Try this super fast analog pin logger

Hello guys,

I already try the code and it works like a charm. I was trying to modify it because I want to start and end the acquisition of data remotely. I bought a cheap RF transmitter and receiver (https://www.sparkfun.com/products/10532 and https://www.sparkfun.com/products/retired/8946) and downloaded the virtualwire library (VirtualWire: VirtualWire library for Arduino and other boards). To start the acquisition I modified the code like this:

void setup(void) {
  if (ERROR_LED_PIN >= 0) {
    pinMode(ERROR_LED_PIN, OUTPUT);
  }
  Serial.begin(9600);
  
  vw_setup(2000);             // Bits per sec
  vw_set_rx_pin(8) ;
  vw_rx_start();              // Start the receiver
  
  // Read the first sample pin to init the ADC.
  analogRead(PIN_LIST[0]);
  
  Serial.print(F("FreeRam: "));
  Serial.println(FreeRam());

  // initialize file system.
  if (!sd.begin(SD_CS_PIN, SPI_FULL_SPEED)) {
    sd.initErrorPrint();
    fatalBlink();
  }
}
//------------------------------------------------------------------------------
void loop(void) {
  Serial.println();
  Serial.println(F("type:"));
  Serial.println(F("c - convert file to CSV")); 
  Serial.println(F("d - dump data to Serial"));  
  Serial.println(F("e - overrun error details"));
  Serial.println(F("r - record ADC data"));

  while(!vw_get_message(message, &msgLength)) {}
  if (ERROR_LED_PIN >= 0) {
    digitalWrite(ERROR_LED_PIN, LOW);
  }
  
  if (message[0] == 'c') 
  {
    binaryToCsv();
  }
  else if (message[0] == 'd')
  {
    dumpData();
  }
  else if (message[0] == 'e')
  {
    checkOverrun();
  }
  else if (message[0] == 'r')
  {
    logData();
  }
  else 
  {
    Serial.println(F("Invalid entry"));
  }
}

So when i send the letter r from my other arduino the one with the sd card starts recording. The problem is when I try to stop it. To do so I modified the logdata function:

    if (vw_get_message(message, &msgLength)) {
      // stop ISR calls
      adcStop();
      if (isrBuf != 0 && isrBuf->count >= PIN_COUNT) {
        // Truncate to last complete sample.
        isrBuf->count = PIN_COUNT*(isrBuf->count/PIN_COUNT);
        // put buffer in full queue
        fullQueue[fullHead] = isrBuf;
        fullHead = queueNext(fullHead);
        isrBuf = 0;
      }
      if (fullHead == fullTail) break;
    }

But the former does not work. I read in the virtualwire documentation that it uses timer1 and I think that is why my code is not working but I don't know how to fix it.

Any advice?

Thanks in advance to you all