Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- #include <DS1307RTC.h>
- #include <Time.h>
- #include <Wire.h>
- #include <DHT.h>
- #define DHTPIN A3
- #define DHTTYPE DHT11
- LiquidCrystal lcd(2,3,4,5,6,7);
- const char *monthName[12] = {
- "01", "02", "03", "04", "05", "06",
- "07", "08", "09", "10", "11", "12"
- };
- int h;
- int t;
- 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();
- pinMode(9, OUTPUT);
- }
- void loop() {
- int jasnosc = analogRead(A1);
- { if (jasnosc <500)
- digitalWrite(9, HIGH);
- else digitalWrite(9, LOW);
- }
- 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);
- LCDprint2digits(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