Arduino 红外发射器不适用于我的电视
Arduino IR Transmittor not working with my TV
我尝试用 Arduino 和红外发射器做我的 DIY 项目。我按照网络中提到的方式连接并编写了代码。但它无法正常工作。
人脉:
第一个 IR 引脚接地
连接到 TX 的第二个 IR 引脚
#include <IRremote.h>
IRsend irsend;
void setup() {}
void loop() {
irsend.sendRC5(0x1FC1, 32);
delay(5000);
}
这是我在 Arduino 中的代码
为了检查串行监视器,我使用了下面的代码
#include <IRremote.h>
const int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
irrecv.blink13(true);
}
void loop() {
if (irrecv.decode(&results)) {
if (results.decode_type == NEC) {
Serial.print("NEC: ");
} else if (results.decode_type == SONY) {
Serial.print("SONY: ");
} else if (results.decode_type == RC5) {
Serial.print("RC5: ");
} else if (results.decode_type == RC6) {
Serial.print("RC6: ");
} else if (results.decode_type == UNKNOWN) {
Serial.print("UNKNOWN: ");
}
Serial.println(results.value, HEX);
irrecv.resume();
}
}
参考:https://www.pjrc.com/teensy/td_libs_IRremote.html
results- 串行监视器:
来自远程:RC5:1FC1
来自 Arduino:RC5:1FC1
两者相同。但我的电视仍然不能与 Arduino 一起使用,但可以与原始遥控器一起使用
可能是什么问题?
我得到了答案,即使它显示警告,我也可以通过以下代码控制我的电视和其他设备。
我使用 NEC
而不是 RC5
#include <IRremote.h>
IRsend irsend;
void setup() {}
void loop() {
irsend.sendNEC(0x1FC1, 32);
delay(5000);
}
我尝试用 Arduino 和红外发射器做我的 DIY 项目。我按照网络中提到的方式连接并编写了代码。但它无法正常工作。
人脉:
第一个 IR 引脚接地
连接到 TX 的第二个 IR 引脚
#include <IRremote.h>
IRsend irsend;
void setup() {}
void loop() {
irsend.sendRC5(0x1FC1, 32);
delay(5000);
}
这是我在 Arduino 中的代码
为了检查串行监视器,我使用了下面的代码
#include <IRremote.h>
const int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
irrecv.blink13(true);
}
void loop() {
if (irrecv.decode(&results)) {
if (results.decode_type == NEC) {
Serial.print("NEC: ");
} else if (results.decode_type == SONY) {
Serial.print("SONY: ");
} else if (results.decode_type == RC5) {
Serial.print("RC5: ");
} else if (results.decode_type == RC6) {
Serial.print("RC6: ");
} else if (results.decode_type == UNKNOWN) {
Serial.print("UNKNOWN: ");
}
Serial.println(results.value, HEX);
irrecv.resume();
}
}
参考:https://www.pjrc.com/teensy/td_libs_IRremote.html
results- 串行监视器: 来自远程:RC5:1FC1 来自 Arduino:RC5:1FC1
两者相同。但我的电视仍然不能与 Arduino 一起使用,但可以与原始遥控器一起使用
可能是什么问题?
我得到了答案,即使它显示警告,我也可以通过以下代码控制我的电视和其他设备。 我使用 NEC
而不是 RC5#include <IRremote.h>
IRsend irsend;
void setup() {}
void loop() {
irsend.sendNEC(0x1FC1, 32);
delay(5000);
}