Personally I take samples of the ADC at several moments within a second.
I use an interrupted based timer (16 Hz), use timeticks within that second (cnt1, 1..16).
Maybe you can use parts of my code and change timersettings.
//Initialize Timer1, preset to 16 Hz timetick
cli(); // disable global interrupts
TCCR1A = 0; // set entire TCCR1A register to 0
TCCR1B = 0; // same for TCCR1B
OCR1A = 15624; // set compare match register to desired timer count:
TCCR1B |= (1 << WGM12); // turn on CTC mode:
TCCR1B |= (1 << CS10); // Set CS10 and CS11 bits for 64 prescaler:
TCCR1B |= (1 << CS11);
TIMSK1 |= (1 << OCIE1A); // enable timer compare interrupt:
//Interrupt every 62.5 ms (16 Hz) with timer 1, written on 20130617
ISR(TIMER1_COMPA_vect)
{
cnt1++; //Increment 62.5 ms counter
if (cnt1 == 17) {cnt1=1;}
}
void Mastercontroller() {
if ((cnt1+1) % 3==0) { Read_analogValues(); } //Take every 2,5,8,11,14 sixteenth of a second samples of analog inputs
if (cnt1==7) {Serial.println("Action..."); } //End if
} //End of function