This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
---|