아두이노에서 리모컨 신호 수신Arduino Uno2015. 2. 19. 18:14
Table of Contents
반응형
라이브러리 설치
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 에러가 남.
실행결과
리모컨 버튼을 누르면 해당 신호를 시리얼 통신을 통해 문자열로 확인 가능하다.
소스코드
- #include <IRremote.h>
- int RECV_PIN = 0;
- 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
- }
- }
반응형
'Arduino Uno' 카테고리의 다른 글
arduino에서 servo 모터 제어 (2) | 2015.11.10 |
---|---|
가변저항으로 조정하여 LED의 밝기 조정하기 (2) | 2015.10.19 |
아두이노 세븐세그먼트 예제 (0) | 2015.02.19 |
Arduino UNO에서 DC 모터 제어 (3) | 2015.02.16 |
아두이노 시뮬레이터 (0) | 2015.02.16 |