eagler8
发表于 2022-7-10 07:39
实验串口绘图器返回情况
eagler8
发表于 2022-7-10 08:06
实验场景图
eagler8
发表于 2022-7-10 09:01
【花雕体验】17 Beetle ESP32C3与WS2812屏音乐可视化节奏灯
实验程序二:简易测量环境声级
模块接线:
MAX9814Beetle ESP32C3
VCC 5V
GND GND
OUT A0
/*
【花雕体验】17 Beetle ESP32C3与WS2812屏音乐可视化节奏灯
实验程序二:简易测量环境声级
模块接线:
MAX9814Beetle ESP32C3
VCC 5V
GND GND
OUT A0
*/
const int sampleWindow = 50; // 以mS为单位的采样窗口宽度(50 mS = 20Hz)
unsigned int sample;
void setup() {
Serial.begin(115200);
pinMode(A0,INPUT);
}
void loop() {
unsigned long startMillis= millis();// 样本窗口的开始
unsigned int peakToPeak = 0; // 峰峰值
unsigned int signalMax = 0;
unsigned int signalMin = 3600;
// collect data for 50 mS
while (millis() - startMillis < sampleWindow)
{
sample = analogRead(A0);
if (sample < 3600)// 抛出错误的读数
{
if (sample > signalMax)
{
signalMax = sample;// 只保存最大级别
}
else if (sample < signalMin)
{
signalMin = sample;// 仅保存最低级别
}
}
}
peakToPeak = signalMax - signalMin;// max-min =峰峰值幅度
double volts = (peakToPeak * 5.0) / 170;
Serial.println(volts);
}
eagler8
发表于 2022-7-10 09:03
实验串口绘图器返回情况(环境噪音)
eagler8
发表于 2022-7-10 09:07
实验串口绘图器返回情况(时事播音)
topdog
发表于 2022-7-10 16:48
MAX9814麦克风放大器模块很好用呀。
eagler8
发表于 2022-7-10 17:29
topdog 发表于 2022-7-10 16:48
MAX9814麦克风放大器模块很好用呀。
:P是啊,几元的,挺好用
eagler8
发表于 2022-7-10 18:43
【花雕体验】17 Beetle ESP32C3与WS2812屏音乐可视化节奏灯
实验程序三:通过快速傅里叶变换在ws2812b灯板上显示频谱
/*
【花雕体验】17 Beetle ESP32C3与WS2812屏音乐可视化节奏灯
实验程序三:通过快速傅里叶变换在ws2812b灯板上显示频谱
*/
#include"arduinoFFT.h"
#include <FastLED.h>
#define NUM_LEDS 256
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
arduinoFFT FFT = arduinoFFT();
CRGB leds;
#define CHANNEL A0
#define DATA_PIN 6
const uint8_t max_bright = 2;
const uint16_t samples = NUM_LEDS / 4;
const byte halfsamples = samples / 2;
uint8_t gHue;
int value;
double vReal;
double vImag;
char toData;
int pointJump;
int uJump;
int dJump;
int uValue;
int dValue;
int tValue;
int toDown = 0;
uint8_t toDownSpeed = 3;
int pointDown = 0;
uint8_t pointDownSpeed = 9;
void setup(){
delay(100);
Serial.println("Ready");
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(max_bright);
}
void loop(){
FastLED.clear();
EVERY_N_MILLISECONDS(10) {
gHue += 10;
}
for (int i = 0; i < samples; i++)
{
value = analogRead(CHANNEL);
vReal = value;
vImag = 0.0;
}
FFT.Windowing(vReal, samples, FFT_WIN_TYP_HAMMING, FFT_FORWARD);
FFT.Compute(vReal, vImag, samples, FFT_FORWARD);
FFT.ComplexToMagnitude(vReal, vImag, samples);
for (int i = 0; i < halfsamples; i++)
{
toData = vReal;
toData = constrain(toData, 0, 100);
toData = map(toData, 0, 100, 1, 7);
}
for (int i = 0; i < halfsamples; i++)
{
uValue = toData;
uJump++;
if (uValue > uJump)
{
uValue = uJump;
}
else
{
uJump = uValue;
}
dValue = uValue;
toDown++;
if (toDown % toDownSpeed == 0)
{
dJump--;
toDown = 0;
}
if (dValue > pointJump)
{
dJump = dValue;
}
else
{
dValue = dJump;
}
tValue = uValue;
pointDown++;
if (pointDown % pointDownSpeed == 0)
{
pointJump--;
pointDown = 0;
}
if (tValue > pointJump)
{
pointJump = tValue;
}
else
{
tValue = pointJump;
}
fill_rainbow(leds + 8 * i, uValue, gHue, 30);
fill_rainbow(leds + 8 * i, dValue, gHue, 30);
fill_solid(leds + 8 * i + tValue, 1, CRGB::White);
}
FastLED.show();
delay(10);
}
eagler8
发表于 2022-7-10 18:47
实验场景图
eagler8
发表于 2022-7-10 18:52
实验的视频记录
https://v.youku.com/v_show/id_XNTg4NTgwNTkyNA==.html?spm=a2hcb.playlsit.page.1
https://v.youku.com/v_show/id_XNTg4NTgwNTkyNA==.html?spm=a2hcb.playlsit.page.1