달력

3

« 2024/3 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

'아두이노 리모컨'에 해당되는 글 1

  1. 2017.10.12 Wemos D1 리모컨 사용하기
2017. 10. 12. 16:51

Wemos D1 리모컨 사용하기 아두이노2017. 10. 12. 16:51

필요 부품

Wemos D1 R2 (통신 기능이 필요 없으면 아두이노를 사면 되겠네요)

리모컨 키트 : 구매처( http://arduinostory.com/goods/goods_view.php?goodsNo=1000000225 )


참고자료 : https://arduino-info.wikispaces.com/IR-RemoteControl


리모컨 수신부 데이터시트

IR-Receiver-AX-1838HS.pdf


+선은 3.3V에 연결하니 잘 동작합니다.

신호선은 14번(SCK/D5)에 연결하면 아래 소스코드로 동작시킬 수 있습니다.

참고로 저는 중간에 제대로 된 자료를 못찾아서 아무렇게나 연결하다가 퍽 소리와 함께 타는 냄새가 나는 것을 경험했습니다.

하지만 동작은 잘 되더군요... 어디가 탄 건지는 아직도 모름;;




소스코드

#ifndef UNIT_TEST

#include <Arduino.h>

#endif

#include <IRremoteESP8266.h>

#include <IRrecv.h>

#include <IRutils.h>


uint16_t RECV_PIN = 14;


IRrecv irrecv(RECV_PIN);


decode_results results;


void setup() {

  Serial.begin(115200);

  irrecv.enableIRIn();  // Start the receiver

}


void loop() {

  if (irrecv.decode(&results)) {

    serialPrintUint64(results.value, HEX);

    Serial.println("");

    irrecv.resume();  // Receive the next value

  }

  delay(100);

}





리모컨 키 맵

FFA250   FF6290  FFE21D

FF22DD  FF02FD  FFC23D

FFE01F   FFA857  FF906F

FF6897   FF9867  FFB04F

            FF18E7

FF10EF   FF38C7  FF5AA5
            FF4AB5




리모컨의 OK키를 누르면 시리얼 모니터에 ON이 출력,

다른 키를 누르면 OFF가 출력되는 기능 추가

#ifndef UNIT_TEST

#include <Arduino.h>

#endif

#include <IRremoteESP8266.h>

#include <IRrecv.h>

#include <IRutils.h>


uint16_t RECV_PIN = 14;


IRrecv irrecv(RECV_PIN);


decode_results results;


void setup() {

  Serial.begin(115200);

  irrecv.enableIRIn();  // Start the receiver

}


void loop() {

  if (irrecv.decode(&results)) {

    serialPrintUint64(results.value, HEX);

    Serial.println("");


    if(results.value == 0xFF38C7){

      Serial.println("ON");

    }else{

      Serial.println("OFF");

    }

    

    irrecv.resume();

  }

  delay(100);


'아두이노' 카테고리의 다른 글

JSON Parsing  (0) 2017.10.12
circuito.io 소개  (0) 2017.10.05
인터럽트 예제(아두이노 우노)  (0) 2017.10.05
아두이노 메모리 간단 정리  (0) 2017.10.05
서보 모터 구동 예제  (0) 2017.10.04
:
Posted by 클레잇