耗材:
1。显然有电源
2个LED灯条。 Esp8266 /节点单片机
3。红外发射器领导者
4。阻力
5。编程电缆
6。arduino ide
7。烙铁 (一些基础焊接)
8。7805 IC (用于使用LED电源作为ESP电源)
9。步骤1: 准备ESP
首先,将 nodemcu 连接到计算机或笔记本电脑。
现在安装 nodemcu 的驱动程序(使用谷歌搜索)。
打开Arduino IDE后(当然需要下载安装),点击Arduino工具栏的Tools,然后点击board,选择board manager,搜索esp8266 installation(需要一定时间完成)
现在从Arduino工具栏中选择“sketch”,选择“include library”,然后选择“manage library”,搜索“iremoteesp8266”并安装它
现在,要仅通过“工具”完成配置,您需要进入“主板”并选择“nodemcu 1.0 (ESP 12-e)”或其他版本的esp8266。
第 2 步:准备和测试 IR LED
首先,我们需要安装
到这里
识别您的 LED 灯带,无论是 24 键还是 44 键(更大)遥控器
在这里获取遥控器代码
安装库后,我们通过连接红外 LED 来准备红外 LED,如图所示。 将红外线连接到它,然后上传以下草图并将红外线指向控制器。 LED 条应闪烁(开和关)// 同时使用 24 键和 44 键遥控器。
这是执行此操作的代码。
#define IR_ OFF 0xF740BF //32 位的红外反射代码
#define IR_ON 0xF7C0
# 包括irsend irsend(4); // 红外引脚
无效设置 () {
irsend.begin();
}
void loop() {
irsend.sendNEC(IR_ON, 32);
延迟 (5000);
irsend.sendNEC(IR_OFF, 32);
延迟 (5000);
}
第 3 步:接线和准备麦克风
我们将只使用 espe8266 A0 的模拟引脚作为模拟信号的输入,并用它来触发基于声音的红外信号
将引脚连接到 A0
将 5V 连接到 VIN(因为节点 MCU 没有 5V 输出)
这样,我们将对准连接的IR LED D2引脚连接到LED灯条的接收器上。
一种
第 4 步:上传代码并准备
#包括
#包括
#define 麦克风引脚 A0
声音;
国际声音1;
const int irPin = 4; // d2IRsend irsend(irPin); void setup() {
Serial.begin(9600);
pinMode (微音素,输入);
pinMode(irPin,输出);}
//红外线代码
#define IR_ BPlus 0xFF3AC5 //
#define IR_ BMinus 0xFFBA45 //
#define IR_ON 0xFF827D //
#define IR_OFF 0xFF02FD //
#define IR_R 0xFF1AE5 //
#define IR_G 0xFF9A65 //
#define IR_B 0xFFA25D //
#define IR_W 0xFF22DD //
#define IR_B1 0xFF2AD5 //
#define IR_B2 0xFFAA55 //
#define IR_B3 0xFF926D //
#define IR_B4 0xFF12ED //
#define IR_B5 0xFF0AF5 //
#define IR_B6 0xFF8A75 //
#define IR_B7 0xFFB24D //
#define IR_B8 0xFF32CD //
#define IR_B9 0xFF38C7 //
#define IR_B10 0xFFB847 //
#define IR_B11 0xFF7887 //
#define IR_B12 0xFFF807 //
#define IR_B13 0xFF18E7 //
#define IR_B14 0xFF9867 //
#define IR_B15 0xFF58A7 //
#define IR_B16 0xFFD827 //
#define IR_UPR 0xFF28D7 //
#define IR_UPG 0xFFA857 //
#define IR_UPB 0xFF6897 //
#define IR_QUICK 0xFFE817 //
#define IR_DOWNR 0xFF08F7 //
#define IR_DOWNG 0xFF8877 //
#define IR_DOWNB 0xFF48B7 //
#define IR_SLOW 0xFFC837 //
#define IR_ DIY1 0xFF30CF //
#define IR_ DIY2 0xFFB04F //
#define IR_ DIY3 0xFF708F //
#define IR_AUTO 0xFFF00F //
#define IR_ DIY4 0xFF10EF //
#define IR_ DIY5 0xFF906F //
#define IR_ DIY6 0xFF50AF //
#define IR_FLASH 0xFFD02F //
#define IR_JUMP3 0xFF20DF //
#define IR_JUMP7 0xFFA05F //
#define IR_FADE3 0xFF609F //
#define IR_FADE7 0xFFE01F //
void loop() {
声音 = 模拟 (microphonePin); // 获取输入音频信号读数
Serial.print (声音); // 输入音频信号读数到串行显示
串行。打印 ( “” );
如果 (声音》415)
{
sound1 = map (声音,415,750,140,255); // 将更高的频率值映射到偏移量以上的150- 255
}
否则,如果 (声音) 340 && 声音《415) // 保持偏移量读数为零刻度 .. 这里的偏移量值在340-415范围内 (偏移量值在1.45v) 。它取决于电路中使用的元件。
{
sound1 = 地图 (声音,340,415,0,9);
}
否则如果 (声音《340》)
{
sound1 = map (声音,0,340,10,139); // 保持低于偏移读数1-139的比例。
}
如果 (sound1》240)
{
irsend.sendNEC(IR_FLASH, 32);
irsend.sendNEC(IR_QUICK, 32);
irsend.sendNEC(IR_QUICK, 32);
irsend.sendNEC(IR_QUICK, 32);
irsend.sendNEC(IR_QUICK, 32);
irsend.sendNEC(IR_QUICK, 32);
irsend.sendNEC(IR_QUICK, 32);
}
否则如果 ((sound1) 》200)
{
irsend.sendNEC(IR_G, 32);
irsend.sendNEC(IR_B, 32);
延迟 (120);}
否则如果 (sound1》160)
{
irsend.sendNEC(IR_R, 32);
irsend.sendNEC(IR_B, 32);
延迟 (120);
}
否则如果 (sound1》120)
{
irsend.sendNEC(IR_B, 32);
延迟 (120);
}
否则如果 (sound1》80)
{
irsend.sendNEC(IR_B, 32);
延迟 (120);
}
否则如果 (sound1》40)
{
irsend.sendNEC(IR_G, 32);
延迟 (120);
}
否则如果 (sound1》10)
{
irsend.sendNEC(IR_R, 32);
延迟 (120);}
其他耗材:
1. 明明有电源
2个LED灯条。 Esp8266 /节点单片机
3. 红外线发射头
4. 阻力
5. 编程电缆
6。arduino ide
7. 烙铁(一些基本的焊接)
8. 7805 IC(用于LED电源作为ESP电源)
9. 第一步:准备ESP
首先,将 nodemcu 连接到计算机或笔记本电脑。
现在安装 nodemcu 的驱动程序(使用谷歌搜索)。
打开Arduino IDE后(当然需要下载安装),点击Arduino工具栏的Tools,然后点击board,选择board manager,搜索esp8266 installation(需要一定时间完成)
现在从Arduino工具栏中选择“sketch”,选择“include library”,然后选择“manage library”,搜索“iremoteesp8266”并安装它
现在,要仅通过“工具”完成配置,您需要进入“主板”并选择“nodemcu 1.0 (ESP 12-e)”或其他版本的esp8266。
第 2 步:准备和测试 IR LED
首先,我们需要安装
到这里
识别您的 LED 灯带,无论是 24 键还是 44 键(更大)遥控器
在这里获取遥控器代码
安装库后,我们通过连接红外 LED 来准备红外 LED,如图所示。 将红外线连接到它,然后上传以下草图并将红外线指向控制器。 LED 灯条应闪烁(亮起和熄灭)。 // 24键和44键遥控器可以同时使用。
这是执行此操作的代码。
#define IR_OFF 0xF740BF //32 位的红外电阻代码
#define IR_ON 0xF7C0
#包括
IRsend irsend(4); // 红外引脚
无效设置 () {
irsend.begin();
}
void loop() {
irsend.sendNEC(IR_ON, 32);
延迟 (5000);
irsend.sendNEC(IR_OFF, 32);
延迟 (5000);
}
第 3 步:接线和准备麦克风
我们将只使用 espe8266 A0 的模拟引脚作为模拟信号的输入,并用它来触发基于声音的红外信号
将引脚连接到 A0
将 5V 连接到 VIN(因为节点 MCU 没有 5V 输出)
这样,我们将对准连接的IR LED D2引脚连接到LED灯条的接收器上。
一种
第 4 步:上传代码并准备
#包括
#包括
#define 麦克风引脚 A0
声音;
国际声音1;
const int irPin = 4; // d2IRsend irsend(irPin);void setup() {
Serial.begin(9600);
pinMode (微音素,输入);
pinMode(irPin,输出);}
//红外线代码
#define IR_BPlus 0xFF3AC5 //
#define IR_BMinus 0xFFBA45 //
#define IR_ON 0xFF827D //
#define IR_OFF 0xFF02FD //
#define IR_R 0xFF1AE5 //
#define IR_G 0xFF9A65 //
#define IR_B 0xFFA25D //
#define IR_W 0xFF22DD //
#define IR_B1 0xFF2AD5 //
#define IR_B2 0xFFAA55 //
#define IR_B3 0xFF926D //
#define IR_B4 0xFF12ED //
#define IR_B5 0xFF0AF5 //
#define IR_B6 0xFF8A75 //
#define IR_B7 0xFFB24D //
#define IR_B8 0xFF32CD //
#define IR_B9 0xFF38C7 //
#define IR_B10 0xFFB847 //
#define IR_B11 0xFF7887 //
#define IR_B12 0xFFF807 //
#define IR_B13 0xFF18E7 //
#define IR_B14 0xFF9867 //
#define IR_B15 0xFF58A7 //
#define IR_B16 0xFFD827 //
#define IR_UPR 0xFF28D7 //
#define IR_UPG 0xFFA857 //
#define IR_UPB 0xFF6897 //
#define IR_QUICK 0xFFE817 //
#define IR_DOWNR 0xFF08F7 //
#define IR_DOWNG 0xFF8877 //
#define IR_DOWNB 0xFF48B7 //
#define IR_SLOW 0xFFC837 //
#define IR_DIY1 0xFF30CF //
#define IR_DIY2 0xFFB04F //
#define IR_DIY3 0xFF708F //
#define IR_AUTO 0xFFF00F //
#define IR_DIY4 0xFF10EF //
#define IR_DIY5 0xFF906F //
#define IR_DIY6 0xFF50AF //
#define IR_FLASH 0xFFD02F //
#define IR_JUMP3 0xFF20DF //
#define IR_JUMP7 0xFFA05F //
#define IR_FADE3 0xFF609F //
#define IR_FADE7 0xFFE01F //
void loop() {
声音 = 模拟 (microphonePin); // 获取输入音频信号读数
Serial.print (声音); // 输入音频信号读数到串行显示
串行。打印 ( “” );
如果 (声音》415)
{
sound1 = map (声音,415,750,140,255); // 将更高的频率值映射到偏移量以上的150- 255
}
否则,如果 (声音) 340 && 声音《415) // 保持偏移量读数为零刻度 .. 这里的偏移量值在340-415范围内 (偏移量值在1.45v) 。它取决于电路中使用的元件。
{
sound1 = 地图 (声音,340,415,0,9);
}
否则如果 (声音《340》)
{
sound1 = map (声音,0,340,10,139); // 保持低于偏移读数1-139的比例。
}
如果 (sound1》240)
{
irsend.sendNEC(IR_FLASH, 32);
irsend.sendNEC(IR_QUICK, 32);
irsend.sendNEC(IR_QUICK, 32);
irsend.sendNEC(IR_QUICK, 32);
irsend.sendNEC(IR_QUICK, 32);
irsend.sendNEC(IR_QUICK, 32);
irsend.sendNEC(IR_QUICK, 32);
}
否则如果 ((sound1) 》200)
{
irsend.sendNEC(IR_G, 32);
irsend.sendNEC(IR_B, 32);
延迟 (120);}
否则如果 (sound1》160)
{
irsend.sendNEC(IR_R, 32);
irsend.sendNEC(IR_B, 32);
延迟 (120);
}
否则如果 (sound1》120)
{
irsend.sendNEC(IR_B, 32);
延迟 (120);
}
否则如果 (sound1》80)
{
irsend.sendNEC(IR_B, 32);
延迟 (120);
}
否则如果 (sound1》40)
{
irsend.sendNEC(IR_G, 32);
延迟 (120);
}
否则如果 (sound1》10)
{
irsend.sendNEC(IR_R, 32);
延迟 (120);}
别的
{
irsend.sendNEC(IR_FADE7, 32);
延迟 (120);
} Serial.println (声音1);
延迟 (50);
}
{
irsend.sendNEC(IR_FADE7, 32);
延迟 (120);
} Serial.println (声音1);
德拉