kamil004

Untitled

Jun 7th, 2015
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.14 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2. #include <DS1307RTC.h>
  3. #include <Time.h>
  4. #include <Wire.h>
  5. #include <DHT.h>
  6. #define DHTPIN A3
  7. #define DHTTYPE DHT11  
  8. LiquidCrystal lcd(2,3,4,5,6,7);
  9.  
  10.  
  11.     const char *monthName[12] = {
  12.       "01", "02", "03", "04", "05", "06",
  13.       "07", "08", "09", "10", "11", "12"
  14.     };
  15.  
  16. int h;
  17. int t;
  18. int jasnosc;
  19. tmElements_t tm;
  20. DHT dht(DHTPIN, DHTTYPE);
  21.  
  22. byte temp[8] = //ikona temperatury
  23. {
  24.     B00100,
  25.     B01010,
  26.     B01010,
  27.     B01110,
  28.     B01110,
  29.     B11111,
  30.     B11111,
  31.     B01110
  32. };
  33. byte wilg[8] = //ikona wilgotnosci
  34. {
  35.     B00100,
  36.     B00100,
  37.     B01010,
  38.     B10001,
  39.     B10001,
  40.     B10001,
  41.     B01110,
  42. };
  43. byte stopnie[8] = //ikona stopni
  44. {
  45.     B01100,
  46.     B10010,
  47.     B10010,
  48.     B01100,
  49.     B00000,
  50.     B00000,
  51.     B00000,
  52.     B00000
  53. };
  54. byte procent[8] = //ikona procentu
  55. {
  56.     B00000,
  57.     B11000,
  58.     B11010,
  59.     B00110,
  60.     B01100,
  61.     B01011,
  62.     B00011,
  63.     B00000
  64. };
  65.  
  66. void setup() {
  67.  
  68.    lcd.begin(16, 2);
  69.    lcd.createChar(0, temp);
  70.    lcd.createChar(1, wilg);
  71.    lcd.createChar(3, stopnie);
  72.    lcd.createChar(4, procent);
  73.    dht.begin();
  74.    pinMode(9, OUTPUT);
  75.  
  76. }
  77.  
  78. void loop() {
  79.  
  80.   int jasnosc = analogRead(A1);
  81.  {   if (jasnosc <500)
  82.    digitalWrite(9, HIGH);
  83.     else digitalWrite(9, LOW);
  84. }
  85.    
  86.    h = dht.readHumidity();
  87.     lcd.setCursor(12,0);
  88.     lcd.print(h);
  89.     lcd.setCursor(14,0);
  90.     lcd.write(byte(4));
  91.     lcd.setCursor(15,0);
  92.     lcd.write(byte(1));
  93.    
  94.    t = dht.readTemperature();
  95.     lcd.setCursor(12,1);
  96.     lcd.print(t);
  97.     lcd.setCursor(14,1);
  98.     lcd.write(byte(3));
  99.     lcd.setCursor(15,1);
  100.     lcd.write(byte(0));
  101.  
  102. if (RTC.read(tm)) {
  103.  
  104.     lcd.setCursor (0, 0);
  105.     LCDprint2digits(tm.Hour);
  106.     lcd.print(':');
  107.     LCDprint2digits(tm.Minute);
  108.     lcd.print(':');
  109.     LCDprint2digits(tm.Second);
  110.     lcd.setCursor (0, 1);
  111.     LCDprint2digits(tm.Day);
  112.     lcd.print('.');
  113.     lcd.print(monthName[tm.Month-1]);
  114.     lcd.print('.');
  115.     lcd.print(tmYearToCalendar(tm.Year));
  116.   }
  117. }
  118.  
  119. void LCDprint2digits(int number) {
  120.   if (number >= 0 && number < 10) {
  121.     lcd.write('0');
  122.   }
  123.   lcd.print(number);  
  124. }
Advertisement
Add Comment
Please, Sign In to add comment