I want to create an ADC using the arduino. I am setting the reference voltage to 0.5V to have a 10 bit resolution for a line-in audio signal. The signal will be coming into an analog pin that reads the value and stores it into an array. The time at which that sample was taken will also be stored into a different array. These values will be processed in pure data. All the arrays and setups have been completed before the adc function is called.
Heres my problem...
I know how to use a for loop, and reading values from the input into an array (I'm an intermediate C programmer). My sampling frequency is 40KHz which means the sample interval will be in the microseconds region. How can I go about writing an adc function that samples the time and amplitude values with a 25us interval? I'm assuming that there will need to be a delay between the analogRead() and storing operations.
Thanks for any help in advanced.