【花雕体验】17 Beetle ESP32C3与WS2812的音乐可视化频谱灯-Arduino中文社区 - Powered by Discuz! Archiver

imhm 发表于 2022-7-12 11:26

厉害。。。

eagler8 发表于 2022-7-12 11:34

imhm 发表于 2022-7-12 11:26
厉害。。。

:handshake 谢谢鼓励

imhm 发表于 2022-7-20 10:44

eagler8 发表于 2022-7-9 16:48
Beetle ESP32-C3是一款基于ESP32-C3 RISC-V 32位单核处理器芯片的主控板,专为物联网 (IoT) 设备而设计。Be ...

合众那个9.9包邮的ESP32-C3能不能做这个频谱灯?

eagler8 发表于 2022-7-20 11:18

imhm 发表于 2022-7-20 10:44
合众那个9.9包邮的ESP32-C3能不能做这个频谱灯?

正在做实验........

【花雕体验】20 音乐可视化:ESP32_C3与WS2812B的系列尝试
https://www.arduino.cn/forum.php?mod=viewthread&tid=109217&fromuid=61537
(出处: Arduino中文社区)

eagler8 发表于 2022-7-20 11:18

imhm 发表于 2022-7-12 11:26
厉害。。。

谢谢鼓励

myself1820 发表于 2022-7-20 20:46

很佩服楼主的钻研精神

eagler8 发表于 2022-7-20 21:06

myself1820 发表于 2022-7-20 20:46
很佩服楼主的钻研精神

:handshake谢谢鼓励,呵呵,比较贪玩

eagler8 发表于 2022-7-21 17:13

【花雕体验】17 Beetle ESP32C3与WS2812屏音乐可视化节奏灯
实验程序四:MegunoLink音乐反应式LED灯带
模块接线:WS2812B接D6
MAX9814   ESP32_C3
VCC          5V
GND         GND
OUT          A0

/*
【花雕体验】17 Beetle ESP32C3与WS2812屏音乐可视化节奏灯
实验程序四:MegunoLink音乐反应式LED灯带
模块接线:WS2812B接D6
MAX9814   ESP32_C3
VCC          5V
GND         GND
OUT          A0
*/

#include<FastLED.h>
#include<MegunoLink.h>
#include<Filter.h>

// define necessary parameters
#define N_PIXELS24
#define MIC_PIN   A0
#define LED_PIN   6
// the following parameters can be tweaked according to your audio levels
#define NOISE 150
#define TOP   (N_PIXELS+2) // allow the max level to be slightly off scale
#define LED_TYPEWS2811
#define BRIGHTNESS18   // a little dim for recording purposes
#define COLOR_ORDER GRB

// declare the LED array
CRGB leds;

// define the variables needed for the audio levels
int lvl = 0, minLvl = 0, maxLvl = 100; // tweak the min and max as needed

// instantiate the filter class for smoothing the raw audio signal
ExponentialFilter<long> ADCFilter(5,0);

void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
// initialize the LED object
FastLED.addLeds<LED_TYPE,LED_PIN,COLOR_ORDER>(leds,N_PIXELS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
}

void loop() {
// put your main code here, to run repeatedly:
// read the audio signal and filter it
int n, height;
n = analogRead(MIC_PIN);
// remove the MX9614 bias of 1.25VDC
n = abs(1023 - n);
// hard limit noise/hum
n = (n <= NOISE) ? 0 : abs(n - NOISE);
// apply the exponential filter to smooth the raw signal
ADCFilter.Filter(n);
lvl = ADCFilter.Current();
//// plot the raw versus filtered signals
//Serial.print(n);
//Serial.print(" ");
//Serial.println(lvl);
// calculate the number of pixels as a percentage of the range
// TO-DO: can be done dynamically by using a running average of min/max audio levels
height = TOP * (lvl - minLvl) / (long)(maxLvl - minLvl);
if(height < 0L) height = 0;
else if(height > TOP) height = TOP;
// turn the LEDs corresponding to the level on/off
for(uint8_t i = 0; i < N_PIXELS; i++) {
    // turn off LEDs above the current level
    if(i >= height) leds = CRGB(0,0,0);
    // otherwise, turn them on!
    else leds = Wheel( map( i, 0, N_PIXELS-1, 30, 150 ) );
}
FastLED.show();
}

CRGB Wheel(byte WheelPos) {
// return a color value based on an input value between 0 and 255
if(WheelPos < 85)
    return CRGB(WheelPos * 3, 255 - WheelPos * 3, 0);
else if(WheelPos < 170) {
    WheelPos -= 85;
    return CRGB(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
    WheelPos -= 170;
    return CRGB(0, WheelPos * 3, 255 - WheelPos * 3);
}
}

eagler8 发表于 2022-7-21 17:20

实验场景图



eagler8 发表于 2022-7-21 17:28

实验场景图动态图 https://img.mydigit.cn/forum/202207/21/172621aefvzqth8y4tvphv.gif






页: 1 2 [3] 4
查看完整版本: 【花雕体验】17 Beetle ESP32C3与WS2812的音乐可视化频谱灯