how can I measure the frequency of sound?

This won't be of much help...

You might want to look-into the FFT & FHT libraries or there is something called autocorrelation. (I've never used any of them.)

Of course, you can't have any delays in your main-read loop....

You also shouldn't print every time through the loop. You need to collect some data, then analyze and print-out. And there's not much RAM so it has to be short samples.

From what I understand, the FFT & FHT libraries don't sample continuously. They pause sampling to do the processing/analysis.