라벨이 적외선 리모컨인 게시물 표시

[Arduino] 아두이노 적외선 수신기(IR Receiver) 사용하기

이미지
아두이노 적외선 수신기(IR Receiver) 사용하기 적외선 수신기는 적외선 리모컨 or 적외선 송신기에서 보내는 신호를 받는다. 리모컨으로 TV, 에어컨, 선풍기 등 제어하는 것 처럼 사용 할 수 있다. 회로도 적외선 수신기 그림이 이상하긴 하지만 회로도 대로 연결 하면 된다. (아무리 찾아도 적외선 수신기 그림이 저거 밖에 없다.) 코드 구현 리모컨이 누른 IR 수신 정보를 출력 해준다. 실행이 안되면 <IR.H>를 추가해야한다. #include <IR.h> //적외선 수신기 사용   #define IR_PIN 13 unsigned long last = millis () ; IRrecv irrecv ( IR_PIN ) ; decode_results decResult; void setup () {   Serial . begin ( 9600 ) ;   irrecv . enableIRIn () ; } void loop () {   if ( irrecv . decode ( &decResult ) == true )   {     Serial . println ( decResult . value , HEX ) ;     Serial . println ( getDecodetype ( decResult . decode_type )) ;     if ( millis () - last > 250 )     {       last = millis () ;       irrecv . resume () ;     }   } } String getDecodetype ( int type) {   String szType= "Typ...