#include <IRrecv.h>
int RECV_PIN = 13;//시그널 핀을 연결d7
int relay = 16;//d0
int humidifier = 5;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
//IR 리시버 시작하기
irrecv.enableIRIn();
//LED
pinMode(relay, OUTPUT);
pinMode(humidifier, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(irrecv.decode(&results)){
unsigned int ircode = results.value;
Serial.println(ircode);
irrecv.resume();//다음 데이터를 수신
//LED 제어
if(ircode == 150167711){ //LED 켜기
digitalWrite(relay, LOW);
delay(1000);
digitalWrite(humidifier, HIGH);
delay(50);
digitalWrite(humidifier, LOW);
} else if (ircode == 150200351){ //LED 끄기
digitalWrite(relay, HIGH);
}
}
delay(100);
}

'IOT > Nodemcu' 카테고리의 다른 글

Nodemcu 시작하기(Arduino IDE)  (0) 2019.05.27

1. https://www.arduino.cc/en/Main/Software Arduino IDE 설치파일 다운로드

2. 파일(File) - 환경설정(Preferences) 에서 추가적인 보드 매니저 URLs(Additional Board Manager URLs) 에 https://arduino.esp8266.com/stable/package_esp8266com_index.json 입력합니다. 기존에 다른 URL이 입력된 경우는 , 로 구분하여 입력합니다.

3. Tool - Board - Board Manager 에서 esp8266 보드를 검색하여 설치합니다.

4. Tool - Board 에서 Generic ESP8266 Module 을 선택합니다.

이로써 Arduino IDE를 통해 Nodemcu 를 개발할 수 있는 환경이 완성됩니다.

'IOT > Nodemcu' 카테고리의 다른 글

Nodemcu로 Relay 제어하기  (0) 2019.05.27

+ Recent posts