声控LED频谱分析仪的制作

第1步:测试您的led
将所有东西布置在适当大小的工作空间上。插入电烙铁。您要做的第一件事就是测试您的led。
我很快了解到这些灯不喜欢在没有数据的情况下响应电源。如果您跳起来尝试仅用电源测试它们而它们不起作用,请稍等片刻。他们可能只需要注入一些代码即可激活led。在切割led灯条之前,请遵循本指南将灯条连接至arduino/电源。然后运行此处找到的示例代码。
注意:一端确实已预焊接了导线。随意尝试一下。在卷轴上,我收到了预包装的电缆,但没有用(哼哼声),所以我不得不切断两个led并从卷轴的裸露端开始。
步骤2:焊接vu防护板
抓住shifty vu防护板和arduino。
vu防护板带有一组接头引脚,用于连接到arduino的。这些接头需要焊接,因为连接太松,甚至不能出于测试目的而简单地插入。有关如何将屏蔽层焊接到arduino的技巧,请参阅sparkfun的这份出色指南。
步骤3:切割led灯条
对于这个项目,我使用了3条带,每条带38个led。
您可以决定要保留多长时间。较短的灯条(少于10个led)可能不会给您带来很大的效果,但是请确定适合您的项目的长度,并相应调整本指南中的步骤。
ldp8806灯带每节带有两个led,每16个led与焊锡相连。您可以在插排的任何点进行切割和连接,但是如果需要在连接点断开插排的连接,请务必拆焊。观看此视频,该视频显示了如何分割这种类型的条带。
步骤4:连接准备
在本指南中,我将使用黑色,红色,黄色和绿色的线。您可以使用所需的任何颜色,但是请记住,在以下步骤中将参考这些颜色。
剥开两端的线以获得每种四种颜色的几根导线。
获取您的led指示灯。您想找到箭头指向远离带状切口的末端。
小心地切掉密封条的末端,这样就可以到达连接器(或将其完全切掉)。
用焊料固定连接器。这样可以更轻松地焊接电线。再次注意箭头的方向;注意它是如何指向远离焊料的。这就是数据流的方向,如果将它们混在一起,可能会损坏条带。
只需检查一下,箭头方向是否正确?如果没有,您将破产。
第5步:连接led
这些led有四个引脚;地,5v,c(时钟)和d(数据)。条带的某些部分上标有值,有些则没有。没关系,只要知道您要焊接到哪个引脚即可。继续操作时请参阅接线图,并仔细检查条带面对的方向。
将条带焊接在一起,确保每个输出都连接到其各自的输入。
第6步:连接到arduino/电源
获取5v电源和arduino。
从在插排布置的输入端开始,将绿色数据线连接到引脚2,将黄色时钟线连接到引脚3。红色5v线直接连接到电源,并且电源和led灯带与驱动器共享公共接地。 arduino。
请参阅上面的接线图,并仔细检查所有连接。
第7步:代码
将arduino连接到您的pc。抓住您的音频分配器并将其连接到pc。使用一根音频电缆连接至vu屏蔽,另一根电缆连接至扬声器。将电源适配器连接到电源插座。
一旦一切都连接好,请从步骤0开始运行测试程序以再次检查所有指示灯是否点亮。
从github下载项目代码并添加到您的arduino库。打开arduino ide并上传。
#include “fix_fft.h”
#include “hsbcolor.h”
#include “lpd8806.h”
#include “spi.h”
// choose 2 pins for arduino output
#define data_pin 2
#define clock_pin 3
// defines the number and arrangement of leds in the visualizer. for a vertical setup, this will determine the space to light ratio as they wrap
#define num_bars 12
#define bar_length 12
// the difference in hue for each bar after the first.
#define bar_hue_diff 8
// create a lpd8806 instance to control the strip
lpd8806 strip = lpd8806(num_bars * bar_length, data_pin, clock_pin);
// the current hue of the first strip of the bar
int curhue = 0;
// fft data storage
char im[num_bars * 2], data[num_bars * 2];
int prev[num_bars];
// hsb/rgb data buffer
int rcolor[3];
// converts a 2d visualizer point to it‘s location on the strip
int getstriplocation(int col, int row)
{
// controls the strip in alternating directions. this allows for chaining horizontal bars end-to-end
if (col % 2 == 0)
row = bar_length - row - 1;
return col * bar_length + row;
}
void setup()
{
analogreference(default);
strip.begin();
strip.show();
}
void loop()
{
uint16_t i, j, k;
uint32_t color;
// read analog input
for (i = 0; i 《 num_bars * 2; i++)
{
int val = (analogread(3) + analogread(2)) / 2;
data[i] = val * 2;
im[i] = 0;
delay(1);
}
// set the background colour of the leds when they are not receiving music data
for (i = 0; i 《 num_bars * bar_length; i++)
strip.setpixelcolor(i, 20, 20, 40);
// set the proper pixels in each bar
for (i = 0; i 《 num_bars; i++)
{
// each led bar has 2 fft frequencies that are summed together
int fft_start = i * 2;
int fft_count = 2;
// get a positive data point from the fft
int curdata = 0;
for (k = 0; k 《 fft_count; k++)
curdata += sqrt(data[fft_start + k] * data[fft_start + k] + im[fft_start + k] * im[fft_start + k]);
// account for the shiftyvu’s filtering
if (i == 0 || i == 7)
curdata /= 2;
// smoothly drop from peaks by only allowing data points to be one led lower than the previous iteration.
// this prevents seizure-inducing flashes which might be caused by the shiftyvu‘s filtering (?)
if (prev[i] 》 bar_length && curdata 《 prev[i] - bar_length)
curdata = prev[i] - bar_length;
// base color for each bar
h2r_hsbtorgb((curhue + i * 8) % 360, 99, 99, rcolor);
color = strip.color(rcolor[0] / 2, rcolor[1] / 2, rcolor[2] / 2);
// if only the first led is lit, but not fully. this is outside the for loop because the subtraction of
// bar_length causes the value to wrap around to a very high number.
if (curdata 《 bar_length)
{
int brightness = curdata * 99 / bar_length;
h2r_hsbtorgb((curhue + i * bar_hue_diff) % 360, 99, brightness, rcolor);
// colour of the base of each bar. change this to match the background colour of the leds
strip.setpixelcolor(i, 20, 20, 40);
}
else
{
for (j = 0; j 《 bar_length; j++)
{
// light up each fully lit led the same way.
if (curdata - bar_length 》 j * bar_length)
strip.setpixelcolor(getstriplocation(i, j), color);
else if (curdata 》 j * bar_length)
{
// dims the last led in the bar based on how close the data point is to the next led.
int brightness = (j * bar_length - curdata) * 99 / bar_length;
h2r_hsbtorgb((curhue + i * bar_hue_diff) % 360, 99, brightness, rcolor);
strip.setpixelcolor(getstriplocation(i, j), strip.color(rcolor[0] / 2, rcolor[1] / 2, rcolor[2] / 2));
}
}
}
// store all of the data points for filtering of the next iteration.
prev[i] = curdata;
}
// cycle through all the colors.
if (curhue == 359)
curhue = 0;
else
curhue++;
// display the strip.
strip.show();
}
步骤8:播放一些音乐
一旦上传了所有内容,就播放一些音乐!现在,您应该具有类似的内容(我的上面覆盖有用于扩散的光面板)。

移动装置测量需求再进化 基础仪器换机潮涌现
汇编驱动IMX6ULL LED灯
Silicon Labs MCU大佬在做原始设计时选了哪些晶体?
所有电子系统都存在的EMI问题
MDN简介以及MDN在视频点播系统中的作用
声控LED频谱分析仪的制作
安防视频能够强势立足的根基在于——它是刚需中的刚需
储能电池管理系统BMS对外输出电源接口保护方案
三星GalaxyFold凉凉?曝三星正研发一款翻盖形式的折叠屏手机
AI的兴起会损害初级律师的技能吗?
通信教程01 什么是并行通信?什么是串行通信?
利用LDC2114与电感式触摸技术设计智能手表按键
磁翻板液位计选型需要考虑的七大因素
三星和苹果创新不足,mate20有利于进一步冲击高端市场
高科技的应用让健身房变得更智能更便捷
云塔电子科技成功研制出全球首对5G与WiFi共存滤波器模组
华芳纺织稳步推进汽车动力电池项目
Linux进程间通信
PS-2205S-RS螺丝扭力测试仪的架构
通过PROFINET通信实现V90 PN基本定位控制