Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <DS1307RTC.h>
- #include <Time.h>
- #include <Wire.h>
- #include <DHT.h>
- //#include <LCD5110_Graph.h>
- #include <LiquidCrystal_I2C.h>
- #define BACKLIGHT_PIN 3
- #define DHTPIN A0
- #define DHTTYPE DHT11
- LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7,3, POSITIVE);
- //LCD5110 myGLCD(10,9,8,6,7);
- //extern uint8_t TinyFont [];
- //extern uint8_t SmallFont[]; // 5110 nokia
- //extern uint8_t MediumNumbers[]; //5110 nokia
- //extern uint8_t BigNumbers [];
- //extern uint8_t termo[];
- //extern uint8_t dwukropek[];
- const char *monthName[12] = {
- "01", "02", "03", "04", "05", "06",
- "07", "08", "09", "10", "11", "12"
- };
- int h;
- int t;
- //int g;
- //int m;
- int jasnosc;
- tmElements_t tm;
- DHT dht(DHTPIN, DHTTYPE);
- byte temp[8] = //ikona temperatury
- {
- B00100,
- B01010,
- B01010,
- B01110,
- B01110,
- B11111,
- B11111,
- B01110
- };
- byte wilg[8] = //ikona wilgotnosci
- {
- B00100,
- B00100,
- B01010,
- B10001,
- B10001,
- B10001,
- B01110,
- };
- byte stopnie[8] = //ikona stopni
- {
- B01100,
- B10010,
- B10010,
- B01100,
- B00000,
- B00000,
- B00000,
- B00000
- };
- byte procent[8] = //ikona procentu
- {
- B00000,
- B11000,
- B11010,
- B00110,
- B01100,
- B01011,
- B00011,
- B00000
- };
- void setup() {
- lcd.begin(16, 2);
- lcd.createChar(0, temp);
- lcd.createChar(1, wilg);
- lcd.createChar(3, stopnie);
- lcd.createChar(4, procent);
- dht.begin();
- // myGLCD.InitLCD();
- // myGLCD.invert(true);
- }
- void loop() {
- // myGLCD.setFont(SmallFont);
- // myGLCD.printNumI(h, LEFT, 41);
- // myGLCD.printNumI(t, RIGHT, 41);
- //
- // myGLCD.setFont(MediumNumbers);
- //
- // g = (tm.Hour);
- // m = (tm.Minute);
- //
- //
- //
- //
- //
- // if (tm.Hour < 10) {
- // myGLCD.print("0", LEFT, 0);
- // myGLCD.printNumI(tm.Hour, 12, 0);} else
- // myGLCD.printNumI(tm.Hour, LEFT, 0);
- //
- // myGLCD.print("-", 23, 0);
- //
- // if (tm.Minute < 10) {
- // myGLCD.print("0", 34, 0);
- // myGLCD.printNumI(tm.Minute, 46, 0);} else
- // myGLCD.printNumI(tm.Minute, 34, 0);
- //
- // myGLCD.setFont(SmallFont);
- // myGLCD.print(":", 57, 9);
- //
- // if (tm.Second < 10) {
- // myGLCD.print("0", 62, 9);
- // myGLCD.printNumI(tm.Second, 68, 9);} else
- // myGLCD.printNumI(tm.Second, 62, 9);
- //
- //
- //
- // myGLCD.drawBitmap(15, 40, termo, 5, 8);
- // myGLCD.update();
- int jasnosc = analogRead(A1);
- { if (jasnosc <500)
- lcd.setBacklight(1);
- else lcd.setBacklight(0);
- }
- // m = tm.Minute();
- h = dht.readHumidity();
- lcd.setCursor(12,0);
- lcd.print(h);
- lcd.setCursor(14,0);
- lcd.write(byte(4));
- lcd.setCursor(15,0);
- lcd.write(byte(1));
- t = dht.readTemperature();
- lcd.setCursor(12,1);
- lcd.print(t);
- lcd.setCursor(14,1);
- lcd.write(byte(3));
- lcd.setCursor(15,1);
- lcd.write(byte(0));
- if (RTC.read(tm)) {
- lcd.setCursor (0, 0);
- LCDprint2digits(tm.Hour);
- lcd.print(':');
- LCDprint2digits(tm.Minute);
- lcd.print(':');
- LCDprint2digits(tm.Second);
- lcd.setCursor (0, 1);
- lcd.print(tm.Day);
- lcd.print('.');
- lcd.print(monthName[tm.Month-1]);
- lcd.print('.');
- lcd.print(tmYearToCalendar(tm.Year));
- }
- }
- void LCDprint2digits(int number) {
- if (number >= 0 && number < 10) {
- lcd.write('0');
- }
- lcd.print(number);
- }
Advertisement
Add Comment
Please, Sign In to add comment