[아두이노] IR Receiver 소스 및 결과 화면
1. 소스
#include <IRremote.h>
const unsigned int IR_RECEIVER_PIN = 11;
const unsigned int BAUD_RATE = 9600;
IRrecv ir_rev(IR_RECEIVER_PIN);
decode_results results;
void setup() {
// put your setup code here, to run once:
Serial.begin(BAUD_RATE);
ir_rev.enableIRIn();
}
void printStatus(const decode_results* results) {
const int protocol = results->decode_type;
if (protocol == UNKNOWN) {
Serial.println("not recognized.");
} else {
Serial.print(results->bits, DEC);
Serial.print(" bits : ");
Serial.println(results->value, HEX);
}
}
void loop() {
// put your main code here, to run repeatedly:
if (ir_rev.decode(&results)) {
printStatus(&results);
ir_rev.resume();
}
}
2. 결과 화면
3. 주의할 점
1) IRremote 라이브러리를 설치해야합니다.
2) 필자의 경우 스케쳐의 버전을 1.0.5 windows 설치버전으로 해야했습니다.
3) 연결은 11번을 output으로 주고 진행했습니다.