Reading the frequency of an analog input

You can use this program to measure it (see attached)
It uses an SD card to write BIN files . It is set up to sample at 40,000 samples per second on A0 input which requires an SD card with low latency. This program is configured for the SD card chip select on pin -10 (D10). If your SD card shield uses pin 4 (D4)
you need to change it

** // Pin definitions.**
//
// Digital pin to indicate an error, set to -1 if not used.
// The led blinks for fatal errors. The led goes on solid for SD write
// overrun errors and logging continues.
const int8_t ERROR_LED_PIN = 3;

// SD chip select pin.
const uint8_t SD_CS_PIN = 10;

This card works well:
http://www.amazon.com/SanDisk-Class-Flash-Memory-SDSDB-004G-AFFP/dp/B007JRB0RY
The program converts the BIN files to EXCEL CSV FILES. The Menu is displayed on the serial monitor.
After you hit any key to stop recording you have to select "c" to convert that file then and there , otherwise you have to remove the card and put in your computer and use the command prompt instructions in the readme file. If your sure you want to use that file make sure to hit "c" after stopping the recording. The conversion can take up to 5 or 10 minutes depending on the file size. A very short run could take less than a minute to convert. You can also dump the data to the serial monitor to view before you choose to convert it. Be sure to connect a led and 220 ohm resistor from D3 output to GND with the (-) lead of the led to ground as the ERROR indicator. If there is an error it will be displayed on the serial monitor. (like overrun error) You can choose to view the overrun error detail on the serial monitor.

The program has four commands:

c - convert file to CSV
d - dump data to Serial
e - overrun error details
r - record ADC data

All commands can be terminated by entering a character from the serial monitor.

The c command converts the current binary file to a text file. Entering a
character on the serial monitor terminates the command.

The d command converts the binary file to text and displays it on the serial
monitor. Entering a character on the serial monitor terminates the command.

The e command displays details about overruns in the current binary file.
Data overruns happen when data samples are lost due to long write latency
of the SD.

The r command will record ADC data to a binary file. It will terminate
when a character is entered on the serial monitor or the the maximum file
block count has been reached.

MyAnalogBinLogger_A0_10_bits_ADC1000_40000_BPS.ino (23.7 KB)

ANALOG05.xlsx (3.42 MB)