我有一块Arduino Mega,以及一个红外发射LED,我想要使用这个LED发送我选择的"十六进制数据",我已经尝试过IRRemote Library并成功使用了IRrecv
类,但是当我使用IRsend
时,我没有收到任何信号,我也尝试用手机相机观察了一下LED。
红外发射引脚是PWM 3,我曾将其连接到3.3V和5V。
#include <IRremote.h>
IRsend irsend;
void setup()
{
Serial.begin(9600);
}
void loop() {
if (Serial.read() != -1) {
for (int i = 0; i < 3; i++) {
irsend.sendSony(0xa90, 12); // Sony TV power code
delay(40);
}
}
}
对于接收者:
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
感谢您的帮助 :) Hiso