https://v.youku.com/v_show/id_XNTg5MjE3MTgxNg==.html?spm=a2hcb.playlsit.page.3
https://v.youku.com/v_show/id_XNTg5MjE3MTgxNg==.html?spm=a2hcb.playlsit.page.3
本帖最后由 驴友花雕 于 2022-8-9 10:06 编辑
找到一个其他家用电器上的塑料盒子。
准备用它来做十位120颗LED彩色音乐节奏灯的底座。
为打这个孔,特意收了几个大规格扩孔器........
没想到效果比预料的好
实验场景图动态图(水杯+水瓶)
实验的视频记录(1分13秒)
https://v.youku.com/v_show/id_XNTg5MjQ2OTEyMA==.html?spm=a2hcb.playlsit.page.1
https://v.youku.com/v_show/id_XNTg5MjQ2OTEyMA==.html?spm=a2hcb.playlsit.page.1
定制的十片灯环,终于到了
水瓶灯座初步成型了
没想到,安装灯环就用了大半天功夫........
简单测试十个灯环120颗LED
【花雕动手做】有趣好玩的音乐可视化系列小项目(14)---水杯水瓶灯
项目程序之四:十位水杯音乐反应灯
模块接线:WS2812B接D7
MAX4466 UNO
VCC 5V
GND GND
OUT A0
/*
【花雕动手做】有趣好玩的音乐可视化系列小项目(14)---水杯水瓶灯
项目程序之四:十位水杯音乐反应灯
模块接线:WS2812B接D7
MAX4466 UNO
VCC 5V
GND GND
OUT A0
*/
#include<FastLED.h>
#define LED_PIN 7
#define NUM_LEDS 120
CRGB leds;
uint8_t hue = 0;
int soundsensor = A0;
void setup() {
delay(2000);
FastLED.setBrightness(130);
pinMode(soundsensor, INPUT);
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
}
void loop() {
int sensval = digitalRead(soundsensor);
if (sensval == 1) {
Serial.println("ON");
leds = CRGB :: Red;
fill_solid(leds, NUM_LEDS, CRGB :: Blue);
rainbow_moving();
FastLED.show();
delay(10);
}
else {
leds = CRGB :: Black;
fill_solid(leds, NUM_LEDS, CRGB :: Black);
FastLED.show();
delay(10);
}
}
void rainbow_moving() {
for (int i = 0; i < NUM_LEDS; i++) {
leds = CHSV(hue + (i * 10), 255, 255);
}
EVERY_N_MILLISECONDS(10) {
hue++;
}
}
实验场景图动态图
实验的视频记录(3分58秒)
https://v.youku.com/v_show/id_XNTg5MzM5NTUyNA==.html?spm=a2hcb.playlsit.page.1
https://v.youku.com/v_show/id_XNTg5MzM5NTUyNA==.html?spm=a2hcb.playlsit.page.1
【花雕动手做】有趣好玩的音乐可视化系列小项目(14)---水杯水瓶灯
项目之四:MegunoLink柱状音乐灯
/*
【花雕动手做】有趣好玩的音乐可视化系列小项目(14)---水杯水瓶灯
项目之四:MegunoLink柱状音乐灯
*/
#include<FastLED.h>
#include<MegunoLink.h>
#include<Filter.h>
#define N_PIXELS120
#define MIC_PIN A0
#define LED_PIN 6
#define NOISE 10
#define TOP (N_PIXELS+2)
#define LED_TYPEWS2811
#define BRIGHTNESS22
#define COLOR_ORDER GRB
CRGB leds;
int lvl = 0, minLvl = 0, maxLvl = 10;
ExponentialFilter<long> ADCFilter(5, 0);
void setup() {
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, N_PIXELS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
int n, height;
n = analogRead(MIC_PIN);
n = abs(1023 - n);
n = (n <= NOISE) ? 0 : abs(n - NOISE);
ADCFilter.Filter(n);
lvl = ADCFilter.Current();
//Serial.print(n);
//Serial.print(" ");
//Serial.println(lvl);
height = TOP * (lvl - minLvl) / (long)(maxLvl - minLvl);
if (height < 0L) height = 0;
else if (height > TOP) height = TOP;
for (uint8_t i = 0; i < N_PIXELS; i++) {
if (i >= height) leds = CRGB(0, 0, 0);
else leds = Wheel( map( i, 0, N_PIXELS - 1, 30, 150 ) );
}
FastLED.show();
}
CRGB Wheel(byte WheelPos) {
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);
}
}
实验场景图动态图
实验的视频记录(1分08秒)
https://v.youku.com/v_show/id_XNTg5MzQ5OTUxNg==.html?spm=a2hcb.playlsit.page.1
https://v.youku.com/v_show/id_XNTg5MzQ5OTUxNg==.html?spm=a2hcb.playlsit.page.1
【花雕动手做】有趣好玩的音乐可视化系列小项目(14)---水杯水瓶灯
项目之五:Arduino 和 FastLED多彩音乐节拍灯
/*
【花雕动手做】有趣好玩的音乐可视化系列小项目(14)---水杯水瓶灯
项目之五:Arduino 和 FastLED多彩音乐节拍灯
*/
#include <FastLED.h>
#define SAMPLEPERIODUS 200
#define MIC_PIN A0
#define LED_DT 6
#define COLOR_ORDER GRB
#define LED_TYPE WS2812
#define NUM_LEDS 120
uint8_t max_bright = 33;
struct CRGB leds;
CRGBPalette16 currentPalette = RainbowColors_p;
CRGBPalette16 targetPalette;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(max_bright);
}
float bassFilter(float sample) {
static float xv = {0, 0, 0}, yv = {0, 0, 0};
xv = xv; xv = xv;
xv = sample / 9.1f;
yv = yv; yv = yv;
yv = (xv - xv) + (-0.7960060012f * yv) + (1.7903124146f * yv);
return yv;
}
float envelopeFilter(float sample) {
static float xv = {0, 0}, yv = {0, 0};
xv = xv;
xv = sample / 160.f;
yv = yv;
yv = (xv + xv) + (0.9875119299f * yv);
return yv;
}
float beatFilter(float sample) {
static float xv = {0, 0, 0}, yv = {0, 0, 0};
xv = xv; xv = xv;
xv = sample / 7.015f;
yv = yv; yv = yv;
yv = (xv - xv) + (-0.7169861741f * yv) + (1.4453653501f * yv);
return yv;
}
void loop() {
unsigned long time = micros();
float sample, value, envelope, beat, thresh, micLev;
for (uint8_t i = 0; ; ++i) {
sample = (float)analogRead(MIC_PIN);
micLev = ((micLev * 67) + sample) / 68;
sample -= micLev;
value = bassFilter(sample);
value = abs(value);
envelope = envelopeFilter(value);
if (i == 200) {
beat = beatFilter(envelope);
thresh = 0.02f * 75.;
if (beat > thresh) {
digitalWrite(LED_BUILTIN, LOW);
int strt = random8(NUM_LEDS / 2);
int ende = strt + random8(NUM_LEDS / 2);
for (int i = strt; i < ende; i++) {
uint8_t index = inoise8(i * 30, millis() + i * 30);
leds = ColorFromPalette(currentPalette, index, 255, LINEARBLEND);
}
} else {
digitalWrite(LED_BUILTIN, HIGH);
}
i = 0;
}
EVERY_N_SECONDS(5) {
uint8_t baseC = random8();
targetPalette = CRGBPalette16(CHSV(baseC + random8(32), 255, random8(128, 255)),
CHSV(baseC + random8(64), 255, random8(128, 255)),
CHSV(baseC + random8(64), 192, random8(128, 255)),
CHSV(baseC + random8(), 255, random8(128, 255)));
}
EVERY_N_MILLISECONDS(50) {
uint8_t maxChanges = 24;
nblendPaletteTowardPalette(currentPalette, targetPalette, maxChanges);
}
EVERY_N_MILLIS(50) {
fadeToBlackBy(leds, NUM_LEDS, 64);
FastLED.show();
}
for (unsigned long up = time + SAMPLEPERIODUS; time > 20 && time < up; time = micros()) {}
} // for i
} // loop()
实验的视频记录(3分59秒)
https://v.youku.com/v_show/id_XNTg5NDg4MjcwNA==.html?spm=a2hcb.playlsit.page.5
https://v.youku.com/v_show/id_XNTg5NDg4MjcwNA==.html?spm=a2hcb.playlsit.page.5
实验的视频记录之二(3分51秒)
https://v.youku.com/v_show/id_XNTg5NDg4MjkyOA==.html?spm=a2hcb.playlsit.page.1
https://v.youku.com/v_show/id_XNTg5NDg4MjkyOA==.html?spm=a2hcb.playlsit.page.1
【花雕动手做】看见声音,基于Arduino系列音乐可视器(1)---LED节奏灯
https://mc.dfrobot.com.cn/thread-311167-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(2)---OLED频谱灯
https://mc.dfrobot.com.cn/thread-311174-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(3)---RGB律动灯
https://mc.dfrobot.com.cn/thread-311183-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(4)---WS2812条灯
https://mc.dfrobot.com.cn/thread-311190-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(5)---WS2812柱跳灯
https://mc.dfrobot.com.cn/thread-311192-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(6)---点阵频谱灯
https://mc.dfrobot.com.cn/thread-311201-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(7)---大方格频谱灯
https://mc.dfrobot.com.cn/thread-311364-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(8)---四位32段点阵屏
https://mc.dfrobot.com.cn/thread-311490-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(9)---X Music Spectrum
https://mc.dfrobot.com.cn/thread-311627-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(10)---WS2812硬板屏
https://mc.dfrobot.com.cn/thread-311641-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(11)---WS2812幻彩灯带
https://mc.dfrobot.com.cn/thread-313648-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(12)---米管快速节奏灯
https://mc.dfrobot.com.cn/thread-313708-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(13)---有机棒立柱灯
https://mc.dfrobot.com.cn/thread-313723-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(14)---水杯水瓶灯
https://mc.dfrobot.com.cn/thread-313803-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(15)--横排LED方管灯
https://mc.dfrobot.com.cn/thread-313811-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(16)--热干胶棒棒灯
https://mc.dfrobot.com.cn/thread-313844-1-1.html
【花雕动手做】有趣好玩音乐可视化系列(17)--光导纤维灯
https://mc.dfrobot.com.cn/thread-313867-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(18)--LED平面板灯
https://mc.dfrobot.com.cn/thread-313951-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(19)--通体光纤灯
https://mc.dfrobot.com.cn/thread-313962-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(20)--首饰盒镜子灯
https://mc.dfrobot.com.cn/thread-313969-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(21)--CD 光盘灯
https://mc.dfrobot.com.cn/thread-313984-1-1.html
【花雕动手做】看见声音,基于Arduino系列音乐可视器(22)--LED无限魔方
https://mc.dfrobot.com.cn/thread-313994-1-1.html
【花雕动手做】有趣好玩的音乐可视化(23)--3合1闪点光纤
https://mc.dfrobot.com.cn/thread-314168-1-1.html
【花雕动手做】有趣好玩的音乐可视化(24)--无限LED镜子灯
https://mc.dfrobot.com.cn/thread-314180-1-1.html
【花雕动手做】有趣好玩音乐可视化(25)--水龙卷旋涡灯
https://mc.dfrobot.com.cn/thread-314231-1-1.html
【花雕动手做】有趣好玩音乐可视化系列(26)--LED 超立方体
https://mc.dfrobot.com.cn/thread-314244-1-1.html
【花雕动手做】有趣好玩的音乐可视化(27)--磁搅LED水旋灯
https://mc.dfrobot.com.cn/thread-314273-1-1.html
页:
1
[2]