#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include "DHT.h"
DHT dht (9 , DHT22 ) ;
#if defined(ARDUINO) && ARDUINO >= 100
#define printByte(args) write(args);
#else
#define printByte(args) print(args,BYTE);
#endif
uint8_t a[8] = {//ธ
B00000,
B11111,
B11110,
B01010,
B01010,
B01010,
B01110,
B00000
};
uint8_t b[8] = {//อั
B00000,
B00001,
B00010,
B00100,
B11000,
B11000,
B00000,
B00000
};
uint8_t c[8] = {//ญ
B00000,
B00000,
B11101,
B10101,
B10101,
B10111,
B00000,
B01111
};
uint8_t d[8] = {//เ
B00000,
B00000,
B01000,
B01000,
B01000,
B01100,
B01100,
B00000
};
uint8_t e[8] = {//ท
B00000,
B00000,
B00000,
B11010,
B01110,
B01010,
B01010,
B00000
};
uint8_t f[8] = {//พ
B00000,
B00000,
B00000,
B11010,
B01110,
B01110,
B01010,
B00000
};
void setup()
{
dht.begin();
}
void loop()
{ LCD1();
LCD2();
}
void LCD1()
{
LiquidCrystal_I2C lcd(0x27,20,4);
lcd.backlight();
lcd.init();
float h = dht.readHumidity();
lcd.setCursor(3, 1);
lcd.println("Humidity");
lcd.print(h,1);
lcd.print("%");
}
void LCD2()
{
LiquidCrystal_I2C lcd(0x26,20,4);
lcd.backlight();
lcd.init();
float t = dht.readTemperature();
lcd.setCursor(1, 3);
lcd.println("Temperature");
lcd.print(t,1);
lcd.print("C");
lcd.createChar(1, a);
lcd.createChar(2, b);
lcd.createChar(3, c);
lcd.createChar(4, d);
lcd.createChar(5, e);
lcd.createChar(6, f);
lcd.setCursor(5, 2);//รหัสนิสิต
lcd.print("632021169");
lcd.setCursor(5, 1); //ชื่อ
lcd.print(" \x01\x03\x04\x05\x06");
lcd.setCursor(5, 0); //
lcd.print(" \x02");
}