반응형

 

 

라이브러리 설치

https://github.com/shirriff/Arduino-IRremote 에 있는 라이브러리를 다운로드 받는다.

https://github.com/shirriff/Arduino-IRremote/archive/master.zip 를 클릭하면 ZIP압축파일로 다운로드 받을 수 있다.

 

압축을 풀은 후.. C:\Users\webnautes\Documents\Arduino\libraries 위치에 붙여 넣었다.

그러면 아두이노 IDE에서 해당 라이브러리와 예제를 사용할 수 있다.

 

그리고 나서 충돌을 피하기 위해 C:\Program Files (x86)\Arduino\librarie\ RobotIRremote를 삭제한다.

그리고 아두이노 IDE를 다시 실행해야 반영이 된다.

 

 

아래와 같이 TSOP2138를 위한 회로를 구성한 후 태스트를 해봤다. 이상하게도 아두이노에 연결한 5V와 그라운드 선을 빼야 프로그램 업로드가 가능했다.

그렇지 않으면 avrdude: stk500_getsync(): not in sync: resp=0x00 에러가 남.

 

실행결과

리모컨 버튼을 누르면 해당 신호를 시리얼 통신을 통해 문자열로 확인 가능하다.

 

소스코드

  1. #include <IRremote.h>  
  2.     
  3. int RECV_PIN = 0;  
  4.     
  5. IRrecv irrecv(RECV_PIN);  
  6.     
  7. decode_results results;  
  8.     
  9. void setup()  
  10. {  
  11.   Serial.begin(9600);  
  12.   irrecv.enableIRIn(); // Start the receiver  
  13. }  
  14.     
  15. void loop() {  
  16.   if (irrecv.decode(&results)) {  
  17.     Serial.println(results.value, HEX);  
  18.     irrecv.resume(); // Receive the next value  
  19.   }  
  20. }  

문제 발생시 지나치지 마시고 댓글 남겨주시면 가능한 빨리 답장드립니다.


제가 쓴 책도 한번 검토해보세요 ^^

+ Recent posts