在Arduino1.85IDE中使用代码如下:
[kenrobot_code]#include <IRremote.h>
int RECV_PIN = 10;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
Serial.println("start receive IR:");
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
dump(&results);
irrecv.resume(); // Receive the next value
}
}
void dump(decode_results *results) {
int count = results->rawlen;
Serial.print("Raw (");
Serial.print(count, DEC);
Serial.print("): ");
for (int i = 0; i < count; i++) {
Serial.print(results->rawbuf*USECPERTICK, DEC);
Serial.print(",");
}
Serial.println("");
}[/kenrobot_code]
接收红外遥控器信号时,出现接收代码不一致问题,接收例子如下:
Raw (68): 37160,8450,4250,500,550,500,1700,450,600,500,1650,500,600,450,1700,500,550,500,1700,500,1700,500,550,500,1700,450,600,500,1650,500,600,450,1700,500,550,500,600,500,1650,500,550,500,1700,500,1700,500,550,500,1700,500,550,500,1700,450,600,500,1650,500,600,450,600,500,1650,500,600,500,1650,500,
Raw (68): 10698,8450,4250,500,550,500,1700,500,550,500,1700,450,600,500,1650,500,600,450,1700,500,1700,500,550,500,1700,500,550,500,1700,450,600,500,1650,500,600,450,600,500,1650,500,600,500,1650,500,1700,500,550,500,1700,500,550,500,1700,450,600,500,1650,500,600,500,550,500,1650,500,600,500,1650,500,
求解
|