2408|25

3386

帖子

0

TA的资源

五彩晶圆(中级)

楼主
 

【花雕动手做】有趣好玩的音乐可视化系列小项目(16)--热干胶棒棒灯 [复制链接]

 

偶然心血来潮,想要做一个声音可视化的系列专题。这个专题的难度有点高,涉及面也比较广泛,相关的FFT和FHT等算法也相当复杂,不过还是打算从最简单的开始,实际动手做做试验,耐心尝试一下各种方案,逐步积累些有用的音乐频谱可视化的资料,也会争取成型一些实用好玩的音乐可视器项目。第16个项目,是使用常见的透明热干胶,来试试棒棒灯。

 

最新回复

带音乐可视器的棒棒灯,用热熔胶棒 期待效果   详情 回复 发表于 2022-8-14 17:17
点赞 关注(1)
 

回复
举报

6997

帖子

0

TA的资源

五彩晶圆(高级)

沙发
 

带音乐可视器的棒棒灯,用热熔胶棒

期待效果

点评

谢谢鼓励  详情 回复 发表于 2022-8-14 17:43
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

板凳
 

WS2812B灯带选用的是每米60灯黑底裸板

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

4
 
Jacktang 发表于 2022-8-14 17:17 带音乐可视器的棒棒灯,用热熔胶棒 期待效果

谢谢鼓励

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

5
 

声音模块,使用性价比更高的MAX4466声音传感器

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

6
 

  【花雕动手做】有趣好玩的音乐可视化系列小项目(16)--热干胶棒棒灯
  项目程序之一:热干胶棒棒音乐反应灯
  模块接线:WS2812B接D6
  MAX4466      UNO
  VCC          5V
  GND         GND
  OUT          A0

 

  • /*
  • 【花雕动手做】有趣好玩的音乐可视化系列小项目(16)--热干胶棒棒灯
  • 项目程序之一:热干胶棒棒音乐反应灯
  • 模块接线:WS2812B接D6
  • MAX4466 UNO
  • VCC 5V
  • GND GND
  • OUT A0
  • */
  • #include<FastLED.h>
  • #define LED_PIN 6
  • #define NUM_LEDS 18
  • CRGB leds[NUM_LEDS];
  • uint8_t hue = 0;
  • int soundsensor = A0;
  • void setup() {
  • delay(2000);
  • FastLED.setBrightness(100);
  • 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[0] = CRGB :: Red;
  • fill_solid(leds, NUM_LEDS, CRGB :: Blue);
  • rainbow_moving();
  • FastLED.show();
  • delay(10);
  • }
  • else {
  • leds[0] = 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[i] = CHSV(hue + (i * 10), 255, 255);
  • }
  • EVERY_N_MILLISECONDS(10) {
  • hue++;
  • }
  • }

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

7
 

实验的视频记录之一(1分05秒)

 

https://v.youku.com/v_show/id_XNTg5NDg2MDE2OA==.html?spm=a2hcb.playlsit.page.3

 


 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

8
 

  【花雕动手做】有趣好玩的音乐可视化系列小项目(16)--热干胶棒棒灯
  项目程序之一:热干胶棒棒音乐节奏灯盘
  模块接线:WS2812B接D6
  MAX4466      UNO
  VCC          5V
  GND         GND
  OUT          A0

 

  • /*
  • 【花雕动手做】有趣好玩的音乐可视化系列小项目(16)--热干胶棒棒灯
  • 项目程序之二:热干胶棒棒音乐节奏灯盘
  • 模块接线:WS2812B接D6
  • MAX4466 UNO
  • VCC 5V
  • GND GND
  • OUT A0
  • */
  • #include<FastLED.h>
  • #include<MegunoLink.h>
  • #include<Filter.h>
  • #define N_PIXELS 69
  • #define MIC_PIN A5
  • #define LED_PIN 12
  • #define NOISE 10
  • #define TOP (N_PIXELS+2)
  • #define LED_TYPE WS2811
  • #define BRIGHTNESS 22
  • #define COLOR_ORDER GRB
  • CRGB leds[N_PIXELS];
  • 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[i] = CRGB(0, 0, 0);
  • else leds[i] = 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);
  • }
  • }

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

9
 

实验场景图  动态图

 

 

点击上图查看Gif动图

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

10
 

实验的视频记录(1分03秒)

 

 

https://v.youku.com/v_show/id_XNTg5NDg2MDIyOA==.html?spm=a2hcb.playlsit.page.1

 


 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

11
 

找到一个装喜糖的小铁盒子

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

12
 

8分位钻孔

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

13
 

10mm扩孔

 

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

14
 

安装热干胶棒

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

15
 

扭个麻花

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

16
 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

17
 

  【花雕动手做】有趣好玩的音乐可视化系列小项目(16)--热干胶棒棒灯
  项目程序之三:测试麻花棒棒灯
  模块接线:WS2812B接D7
  MAX4466      UNO
  VCC          5V
  GND         GND
  OUT          A0

 

  • /*
  • 【花雕动手做】有趣好玩的音乐可视化系列小项目(16)--热干胶棒棒灯
  • 项目程序之三:测试麻花棒棒灯
  • 模块接线:WS2812B接D7
  • MAX4466 UNO
  • VCC 5V
  • GND GND
  • OUT A0
  • */
  • #include <Adafruit_NeoPixel.h>
  • #ifdef __AVR__
  • #include <avr/power.h>
  • #endif
  • #define PIN 7
  • // Parameter 1 = number of pixels in strip
  • // Parameter 2 = Arduino pin number (most are valid)
  • // Parameter 3 = pixel type flags, add together as needed:
  • // NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
  • // NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
  • // NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
  • // NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
  • // NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
  • Adafruit_NeoPixel strip = Adafruit_NeoPixel(64, PIN, NEO_GRB + NEO_KHZ800);
  • // IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
  • // pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
  • // and minimize distance between Arduino and first pixel. Avoid connecting
  • // on a live circuit...if you must, connect GND first.
  • void setup() {
  • // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
  • #if defined (__AVR_ATtiny85__)
  • if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  • #endif
  • // End of trinket special code
  • strip.begin();
  • strip.show(); // Initialize all pixels to 'off'
  • }
  • void loop() {
  • // Some example procedures showing how to display to the pixels:
  • //colorWipe(strip.Color(255, 0, 0), 50); // Red
  • // colorWipe(strip.Color(0, 255, 0), 50); // Green
  • //colorWipe(strip.Color(0, 0, 255), 50); // Blue
  • //colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW
  • // Send a theater pixel chase in...
  • // theaterChase(strip.Color(127, 127, 127), 50); // White
  • //theaterChase(strip.Color(127, 0, 0), 50); // Red
  • //theaterChase(strip.Color(0, 0, 127), 50); // Blue
  • rainbow(20);
  • //rainbowCycle(20);
  • //theaterChaseRainbow(50);
  • }
  • // Fill the dots one after the other with a color
  • void colorWipe(uint32_t c, uint8_t wait) {
  • for(uint16_t i=0; i<strip.numPixels(); i++) {
  • strip.setPixelColor(i, c);
  • strip.show();
  • delay(wait);
  • }
  • }
  • void rainbow(uint8_t wait) {
  • uint16_t i, j;
  • for(j=0; j<256; j++) {
  • for(i=0; i<strip.numPixels(); i++) {
  • strip.setPixelColor(i, Wheel((i+j) & 255));
  • }
  • strip.show();
  • delay(wait);
  • }
  • }
  • // Slightly different, this makes the rainbow equally distributed throughout
  • void rainbowCycle(uint8_t wait) {
  • uint16_t i, j;
  • for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
  • for(i=0; i< strip.numPixels(); i++) {
  • strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
  • }
  • strip.show();
  • delay(wait);
  • }
  • }
  • //Theatre-style crawling lights.
  • void theaterChase(uint32_t c, uint8_t wait) {
  • for (int j=0; j<10; j++) { //do 10 cycles of chasing
  • for (int q=0; q < 3; q++) {
  • for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
  • strip.setPixelColor(i+q, c); //turn every third pixel on
  • }
  • strip.show();
  • delay(wait);
  • for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
  • strip.setPixelColor(i+q, 0); //turn every third pixel off
  • }
  • }
  • }
  • }
  • //Theatre-style crawling lights with rainbow effect
  • void theaterChaseRainbow(uint8_t wait) {
  • for (int j=0; j < 256; j++) { // cycle all 256 colors in the wheel
  • for (int q=0; q < 3; q++) {
  • for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
  • strip.setPixelColor(i+q, Wheel( (i+j) % 255)); //turn every third pixel on
  • }
  • strip.show();
  • delay(wait);
  • for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
  • strip.setPixelColor(i+q, 0); //turn every third pixel off
  • }
  • }
  • }
  • }
  • // Input a value 0 to 255 to get a color value.
  • // The colours are a transition r - g - b - back to r.
  • uint32_t Wheel(byte WheelPos) {
  • WheelPos = 255 - WheelPos;
  • if(WheelPos < 85) {
  • return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  • }
  • if(WheelPos < 170) {
  • WheelPos -= 85;
  • return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  • }
  • WheelPos -= 170;
  • return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  • }

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

18
 

实验场景图

 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

19
 

实验的视频记录(1分05秒)

 

 

https://v.youku.com/v_show/id_XNTg5Mzc1ODQ1Mg==.html?spm=a2hcb.playlsit.page.1

 


 

 
 
 

回复

3386

帖子

0

TA的资源

五彩晶圆(中级)

20
 

  【花雕动手做】有趣好玩的音乐可视化系列小项目(16)--热干胶棒棒灯
  项目程序之四:音乐反应麻花棒棒灯
  模块接线:WS2812B接D6
  MAX4466      UNO
  VCC          5V
  GND         GND
  OUT          D7

 

  • /*
  • 【花雕动手做】有趣好玩的音乐可视化系列小项目(16)--热干胶棒棒灯
  • 项目程序之四:音乐反应麻花棒棒灯
  • 模块接线:WS2812B接D6
  • MAX4466 UNO
  • VCC 5V
  • GND GND
  • OUT D7
  • */
  • #include<FastLED.h>
  • #define LED_PIN 6
  • #define NUM_LEDS 12
  • CRGB leds[NUM_LEDS];
  • uint8_t hue = 0;
  • int soundsensor = 7;
  • void setup() {
  • delay(2000);
  • Serial.begin(9600);
  • FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
  • FastLED.setBrightness(155);
  • pinMode(soundsensor, INPUT);
  • }
  • void loop() {
  • int sensval = digitalRead(soundsensor);
  • if (sensval == 1) {
  • Serial.println("ON");
  • leds[0] = CRGB :: Red;
  • fill_solid(leds, NUM_LEDS, CRGB :: Blue);
  • rainbow_moving();
  • FastLED.show();
  • delay(10);
  • }
  • else {
  • leds[0] = 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[i] = CHSV(hue + (i * 10), 255, 255);
  • }
  • EVERY_N_MILLISECONDS(10) {
  • hue++;
  • }
  • }

 

 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条
报名最后一周!2025 英飞凌消费、计算与通讯创新大会-北京站
会议时间:3月18日(周二)09:30签到
参会奖励:电动螺丝刀套装、户外登山包、京东卡

查看 »

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

 
机器人开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表