[ create a new paste ] login | about

Link: http://codepad.org/C47v8fVI    [ raw code | fork | 5 comments ]

C++, pasted on Oct 9:
/*
    Arduino.vn
    Đọc nhiệt độ - độ ẩm và xuất ra màn hình LCD
    thienvk
*/

#include <wire.h>
#include <ds3231.h>
#include <liquidcrystal_i2c.h>
#include "DHT.h"

const int DHTPIN = 2;
const int DHTTYPE = DHT11;

DHT dht(DHTPIN, DHTTYPE);

byte degree[8] =
{
	0B01110,
	0B01010,
	0B01110,
	0B00000,
	0B00000,
	0B00000,
	0B00000,
	0B00000
};

DS3231 clock;
RTCDateTime dt;
LiquidCrystal_I2C lcd(0x27,16,2);

void setup()
{
	Serial.begin(9600);
	dht.begin();
	
	lcd.init();
	lcd.createChar(1, degree);
	
	clock.begin();
	clock.setDateTime(__DATE__, __TIME__);
}

void loop()
{
	float h = dht.readHumidity();
	float t = dht.readTemperature();
	
	dt = clock.getDateTime();

	lcd.backlight();

	lcd.setCursor(0,0);
	lcd.print(dt.hour);
	lcd.print(":");
	lcd.print(dt.minute);
	lcd.print(":");
	lcd.print(dt.second);
	lcd.print(" ");

	lcd.setCursor(0,1);
	lcd.print(dt.day);
	lcd.print("/");
	lcd.print(dt.month);
	lcd.print("/");
	lcd.print(dt.year);
	lcd.print(" ");

	if (isnan(t) || isnan(h))
	{
	}
	else
	{
		lcd.setCursor(10,0);
		lcd.print("T:");
		lcd.print(round(t));
		lcd.write(1);
		lcd.print("C");

		lcd.setCursor(11,1);
		lcd.print("H:");
		lcd.print(round(h));
		lcd.print("%");
	}
	
	delay(1000);
}


Create a new paste based on this one


Comments:
posted by longngo2608 on Feb 6
cho e hỏi cái:
#include <wire.h>
thư viện này là sao???
reply
posted by dongnguyen on Oct 25

reply
posted by dongnguyen on Oct 25
cho em xin đấu nối,,,em cảm ơn ạ...

reply
posted by PhucVo on May 22
lỗi chỗ RTCDateTime bạn ơi???
reply
posted by PhucVo_1501 on May 22
lỗi chỗ RTCDateTime bạn ơi???
reply