Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

43 lines
1.3KB

  1. /* SPH0645 MEMS Microphone Test (Adafruit product #3421)
  2. *
  3. * Forum thread with connection details and other info:
  4. * https://forum.pjrc.com/threads/60599?p=238070&viewfull=1#post238070
  5. */
  6. #include <Audio.h>
  7. // GUItool: begin automatically generated code
  8. AudioInputI2S i2s1; //xy=180,111
  9. AudioFilterStateVariable filter1; //xy=325,101
  10. AudioAmplifier amp1; //xy=470,93
  11. AudioAnalyzeFFT1024 fft1024_1; //xy=616,102
  12. AudioConnection patchCord1(i2s1, 0, filter1, 0);
  13. AudioConnection patchCord2(filter1, 2, amp1, 0);
  14. AudioConnection patchCord3(amp1, fft1024_1);
  15. // GUItool: end automatically generated code
  16. void setup() {
  17. AudioMemory(50);
  18. filter1.frequency(30); // filter out DC & extremely low frequencies
  19. amp1.gain(8.5); // amplify sign to useful range
  20. }
  21. void loop() {
  22. if (fft1024_1.available()) {
  23. // each time new FFT data is available
  24. // print 20 bins to the Arduino Serial Monitor
  25. Serial.print("FFT: ");
  26. for (int i = 0; i < 20; i++) {
  27. float n = fft1024_1.read(i);
  28. if (n >= 0.001) {
  29. Serial.print(n, 3);
  30. Serial.print(" ");
  31. } else {
  32. Serial.print(" -- "); // don't print "0.000"
  33. }
  34. }
  35. Serial.println();
  36. }
  37. }