c++ - 从 Beaglebone 发送 IR NEC 信号
问题描述
我的部分项目需要我发送一个 IR 信号来改变遥控 RGB 泛光灯的颜色。首先,我使用 Arduino 解码从遥控器发送的信号。然后我开始编写一个内核模块来发送这个信号。由于我在 Beaglebone Black 中使用的是 Linux 内核的 buildroot 版本,因此我无法使用许多库。我将这些值存储在两个数组中:
int RED[] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1};
int BLUE[] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1};
这包含地址、反向地址、命令和反向命令。然后我将像这样运行 IR 信号:
void preamble(void){
gpio_set_value(IR_LED, HIGH);
mdelay(9);
gpio_set_value(IR_LED, LOW);
udelay(1000);
udelay(1000);
udelay(1000);
udelay(1000);
udelay(500);
}
void color_changer(int color){
int *color_command;
int bitl;
int i;
switch(color){
case 1:
color_command = RED;
break;
case 2:
color_command = BLUE;
break;
}
preamble();
for(i = 0; i< sizeof(color_command); i++){
bitl = color_command[i];
if (bitl == 1){
gpio_set_value(IR_LED, HIGH);
ndelay(562500);
gpio_set_value(IR_LED, LOW);
ndelay(1687500);
}
else if(bitl == 0){
gpio_set_value(IR_LED, HIGH);
ndelay(562500);
gpio_set_value(IR_LED, LOW);
ndelay(562500);
}
}
gpio_set_value(IR_LED, HIGH);
ndelay(562500);
gpio_set_value(IR_LED, LOW);
}
但是,泛光灯不会改变颜色,我的 Arduino 也不会检测到任何信号。我试过的接线是:GPIO 67 -> 330Ohm Resistor -> IR LED -> Ground
以及此处描述的内容(我相应地更改了代码以考虑低电平有效设置)。我的代码有什么问题还是我错过了其他东西?
解决方案
推荐阅读
- plotly - color_continuous_scale 是 plotly python 的有效函数?
- python - 用 Python 下载播客
- c# - 更新在 OwnsMany 值对象关系 EF Core 5 中不起作用
- yii2 - 如何在 yii2-export 中为按钮添加类
- python - 如何让 Discord.py 音乐机器人自动播放队列中的下一首歌曲
- python - Django:将变量存储在数据库中并在不同模块之间传递它们
- python - 面试题中等,请大家帮忙
- reactjs - “DetailedHTMLProps”类型上不存在属性“索引”
, HTMLLI元素> - node.js - 将消息发送到机器人所在的所有服务器
- pytorch - 带有 CUDA10.2 的 GPU Pytorch 和带有 CUDA11.1 的 GPU Pytorch