#include <MSGEQ7.h>
#include <Adafruit_NeoPixel.h>
#define MIN_K_value 100
#define MAX_K_value 200
int K_value = 100;
MSGEQ7 eq;
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(130, 6, NEO_GRB + NEO_KHZ800);
uint32_t color_map[130] =
{ //위치별 픽셀 색상설정. 마음에 드는 색조합을 맞추어보세요!
0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,
0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,
0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,
0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,
0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,
0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,
0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,
0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,
0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,
0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,0x00efef00,0x00efef00,0x00efef00,0x00efef00,0x005050af,
}
;
void setup() {
eq.init();//스펙트럼 쉴드를 사용하기 시작합니다.
pixels.begin();//네오픽셀을 사용하기 시작합니다.
pixels.clear();//네오픽셀을 사용하기 시작합니다.
}
int cnt = 0;
void loop() {
eq.poll();//오디오 정보를 갱신합니다.
int max_v = 0;
pixels.clear();
for(int i = 0;i < 7;i++){//입력받은 신호에 따라 네오픽셀을 제어합니다.
int l = eq.getLValue(i);
int r = eq.getRValue(i);
int v = (l<r? r:l);
max_v = (v>max_v? v:max_v);
for(int j = 0;j < 5;j++){
if(v > K_value*(5-j)){
on_pixel(i+(8*j));
}
}
}
for(int j = 0;j < 5;j++){//최대음량을 마지막 줄에 표시합니다.
if(max_v > K_value*(5-j)){
on_pixel(7+(8*j));
}
}
K_value = constrain(max_v/5,MIN_K_value,MAX_K_value);//5등분 분할의 기준을 음악의 최대값의 크기에 맞게 조절합니다.
pixels.show();
delay(100);
}
void on_pixel(int index){
pixels.setPixelColor(index, color_map[index]);//각위치에 맞는 색상을 선택합니다.
}
제가 이 코드로 네오픽셀과 스펙트럼 쉴드를 이용한 이퀄라이저를 만들어보려고 하는데요, 계속 컴파일 오류가 납니다.
오류메세지는 아래와 같습니다.
아두이노:1.8.5 (Windows 10), 보드:"Arduino/Genuino Uno"
sketch_dec09a:11: error: 'MSGEQ7' does not name a type
MSGEQ7 eq;
^
C:\Users\handongwoo\Documents\Arduino\sketch_dec09a\sketch_dec09a.ino: In function 'void setup()':
sketch_dec09a:45: error: 'eq' was not declared in this scope
eq.init();//?뒪?럺?듃?읆 ?돱?뱶瑜? ?궗?슜?븯湲? ?떆?옉?빀?땲?떎.
^
C:\Users\handongwoo\Documents\Arduino\sketch_dec09a\sketch_dec09a.ino: In function 'void loop()':
sketch_dec09a:57: error: 'eq' was not declared in this scope
eq.poll();//?삤?뵒?삤 ?젙蹂대?? 媛깆떊?빀?땲?떎.
^
exit status 1
'MSGEQ7' does not name a type
왜 이러한 오류가 나는지 알고싶습니다.
감사합니다.
|