我正在尝试读取正弦波信号的频率,它是从扬声器(音频信号)生成的,所以它不是单个正弦波信号;在示波器上,它显示为多个信号。 问题是,当我试图读取此信号的频率时,它总是给我0.我正在使用带有以下代码的FreqCounter库,对解决方案的任何建议:
#include <FreqCounter.h>
void setup() {
Serial.begin(9600); // connect to the serial port
Serial.println("Frequency Counter");
}
long int frq;
void loop() {
FreqCounter::f_comp= 8; // Set compensation to 12
FreqCounter::start(100); // Start counting with gatetime of 100ms
while (FreqCounter::f_ready == 0) // wait until counter ready
frq=FreqCounter::f_freq; // read result
Serial.println(frq); // print result
delay(20);
}