BASIC4MCU | 질문게시판 | 아두이노 코드
페이지 정보
작성자 ddkfjw 작성일2018-06-07 16:07 조회6,963회 댓글0건본문
사운드센서에 입력된값을 주파수변환하여 나타내고싶습니다
이 코드가 맞는지 확인하고싶습니다
플로터모니터에 소리를내면 반응을하는데 이게 주파수반응인지 데시벨반응인지 모르겠습니다
알려주실분 계신가요? 부탁드립니다
#define LOG_OUT 1 // use the log output function
#define FFT_N 64 // set to 64 point fft
#define AUDIO_IN 0
#include <FFT.h> // include the library
void setup() {Serial.begin(9600); // use the serial port
}
void loop() {
noInterrupts(); // Enter critical section to reduces jitter
for (int i = 0 ; i < (FFT_N*2) ; i += 2) { // save signal samples
int k = analogRead(AUDIO_IN);
//k -= 0x0200; // form into a signed int
//k <<= 6; // form into a 16b signed int
fft_input[i] = k; // put real data into even bins
fft_input[i+1] = 0; // set odd bins to 0
}
interrupts(); // Escape from critical section
fft_window(); // window the data for better frequency response
fft_reorder(); // reorder the data before doing the fft
fft_run(); // process the data in the fft
fft_mag_log(); // take the output of the fft
Serial.println("start");
for (byte i = 0 ; i < FFT_N/2 ; i++ ){
Serial.println(fft_log_out[i]); // send out the data
delay(10);
}}
댓글 0
조회수 6,963등록된 댓글이 없습니다.