BASIC4MCU | 질문게시판 | 답변 : 아두이노 SimpleDHT LiquidCrystal_I2C
페이지 정보
작성자 master 작성일2018-06-18 17:19 조회11,685회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=1979
본문
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2018-06-18 오후 5:22:41// by Ok-Hyun Park//#include <SimpleDHT.h>SimpleDHT11 dht11;//#include <LiquidCrystal_I2C.h>LiquidCrystal_I2C lcd(0x3F,16,2);//int flame=A0;int Beep =8; // 피에조부저//int pinDHT11=2;int ledPin1=11; // 1번 LEDint ledPin2=10; // 2번 LEDint PIRsensor=9; // 센서 신호핀//int val=0,pirState=0;//void setup(){pinMode(ledPin1,OUTPUT); pinMode(ledPin2,OUTPUT); // LEDpinMode(Beep,OUTPUT);lcd.init(); lcd.backlight();Serial.begin(9600);}//void loop(){val=digitalRead(PIRsensor); Serial.print("PIR="); Serial.println(val); // PIRif(val){ // 센서 신호값이 HIGH면(인체 감지가 되면)if(pirState==LOW){digitalWrite(ledPin1,HIGH); digitalWrite(ledPin2,LOW);pirState=HIGH; Serial.println("Welcome!");}}else{ // 인체감지가 없으면if(pirState==HIGH){digitalWrite(ledPin1,LOW); digitalWrite(ledPin2,HIGH);pirState=LOW; Serial.println("Good Bye~");}}//val=analogRead(flame); Serial.print("Flame="); Serial.println(val); // 화재센서if(val>=300)digitalWrite(Beep,HIGH);else digitalWrite(Beep,LOW);//byte temperature=0;byte humidity=0;//dht11.read(pinDHT11,&temperature,&humidity,NULL);//Serial.print((int)temperature); Serial.print("*C,");Serial.print((int)humidity); Serial.println("%");//lcd.clear();lcd.print((int)temperature); lcd.print("*C,");lcd.print((int)humidity); lcd.print("%");//delay(1000); // DHT11 sampling rate is 1HZ.}
댓글 0
조회수 11,685등록된 댓글이 없습니다.