BASIC4MCU | 질문게시판 | 답변 : 지식in에 답변주신 내용 코드 질문입니다
페이지 정보
작성자 master 작성일2019-12-20 09:30 조회3,037회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=11269
본문
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2019-12-20 오전 9:30:11// by Ok-Hyun Park//#include <stdio.h>//#include <LiquidCrystal_I2C.h>LiquidCrystal_I2C lcd(0x27,16,2);//#include "DHT.h"#define DHTPIN 2 // what digital pin we're connected to#define DHTTYPE DHT11 // DHT 11DHT dht(DHTPIN,DHTTYPE);//int ledPin=13;//char str[50];int err=0;long t,t1,t2,ton,tall;float humi,tem;//void setup(){pinMode(ledPin,OUTPUT);lcd.init(); lcd.backlight(); lcd.print("start");Serial.begin(9600);t=t1=t2=millis();}//void loop(){t=millis();if(t-t1>=1000){ t1=t; // 1초에 1번씩 습도 센서 체크humi=dht.readHumidity();tem=dht.readTemperature();onOff(humi);lcdHumidity(humi);}}//void onOff(float h){if (h<=49){ ton=2000; tall= 5000; }else if(h<=70){ ton=5000; tall=11000; }else { ton=3000; tall= 7000; }//if (t-t2<ton )digitalWrite(ledPin,1);else if(t-t2<tall)digitalWrite(ledPin,0);else t2=t;}//void lcdHumidity(float hu){int h=(int)hu;sprintf(str,"humidity:%d%%\r\n",h); Serial.println(str);sprintf(str,"humidity:%d%%",h); lcd.setCursor(0,0); lcd.print(str);}
라이브러리를 제대로 설치하고
라이브러리에 맞는 예제를 참고해서 작성하세요
라이브러리 설치하면 예제가 함께 설치 됩니다.
댓글 0
조회수 3,037등록된 댓글이 없습니다.