Benutzer-Werkzeuge

Webseiten-Werkzeuge


arduino:spektrumanalysator:programmversion_0.1

Spektrumanalysator Programmversion 0.1

Diese Programmversion gibt das Ergebnis einer FFT an die serielle Schnittstelle aus.

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>


  // GUItool: begin automatically generated code
  AudioInputAnalog         adc1;           //xy=144,93
  AudioAnalyzePeak         peak1;          //xy=342,98
  AudioAnalyzeFFT1024      fft1024_1;      //xy=348,149
  AudioConnection          patchCord1(adc1, peak1);
  AudioConnection          patchCord2(adc1, fft1024_1);
  // GUItool: end automatically generated code

void setup() {
  Serial.begin(115200);  
   AudioMemory(10);
  // Configure the window algorithm to use
  fft1024_1.windowFunction(AudioWindowHanning1024);
  //myFFT.windowFunction(NULL);
}

void loop() {
  // put your main code here, to run repeatedly:
  float n;
  int i;

  if (fft1024_1.available()) {
    // each time new FFT data is available
    // print it all to the Arduino Serial Monitor
    Serial.print("FFT: ");
    for (i=0; i<40; i++) {
      n = fft1024_1.read(i);
      if (n >= 0.01) {
        Serial.print(n);
        Serial.print(" ");
      } else {
        Serial.print("  -  "); // don't print "0.00"
      }
    }
    
    if (peak1.available()) {
      int monoPeak = peak1.read() * 30.0;
      Serial.print(" peak:");
      Serial.print(monoPeak);
    }    
    
    // Serieller Output
    //Serial.print(" cpu:");
    //Serial.print(AudioProcessorUsageMax());
    //Serial.print(" mem:");
    //Serial.print(AudioMemoryUsageMax());
    
    Serial.println();
  }  
}
arduino/spektrumanalysator/programmversion_0.1.txt · Zuletzt geändert: 18.05.2023 12:34 von 127.0.0.1