Advertisement
Guest User

Untitled

a guest
Feb 2nd, 2019
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <LiquidCrystal_PCF8574.h>
  3. #include <OneWire.h>
  4. #include <DS18B20.h>
  5.  
  6. #define ONEWIRE_PIN 3
  7.  
  8. #define SENSORS_NUM 2
  9.  
  10. const byte address[SENSORS_NUM][8] PROGMEM = {
  11. 0x28, 0xFF, 0xA0, 0xD0, 0x47, 0x16, 0x3, 0x95,
  12. 0x28, 0xFF, 0x73, 0x12, 0x47, 0x16, 0x3, 0xBB
  13. };
  14.  
  15. OneWire onewire(ONEWIRE_PIN);
  16. DS18B20 sensors(&onewire);
  17.  
  18. LiquidCrystal_PCF8574 lcd(0x27);  // set the LCD address to 0x27 for a 16 chars and 2 line display
  19.  
  20. int show;
  21.  
  22. void setup()
  23. {
  24.   int error;
  25.  
  26.   Serial.begin(115200);
  27.   Serial.println("LCD...");
  28.  
  29.   while (! Serial);
  30.  
  31.   Serial.println("Dose: check for LCD");
  32.  
  33.   // See http://playground.arduino.cc/Main/I2cScanner
  34.   Wire.begin();
  35.   Wire.beginTransmission(0x27);
  36.   error = Wire.endTransmission();
  37.   Serial.print("Error: ");
  38.   Serial.print(error);
  39.  
  40.   if (error == 0) {
  41.     Serial.println(": LCD found.");
  42.  
  43.   } else {
  44.     Serial.println(": LCD not found.");
  45.   } // if
  46.  
  47.   lcd.begin(16, 2); // initialize the lcd
  48.   show = 0;
  49.  
  50.   Serial.begin(9600);
  51.  
  52.   sensors.begin();
  53.   sensors.request();
  54.  
  55. } // setup()
  56.  
  57. void loop()
  58. {
  59.    lcd.setBacklight(255);    
  60.  
  61.     if (sensors.available())
  62.     {
  63.           float temperature0 = sensors.readTemperature(FA(address[0]));
  64.           float temperature1 = sensors.readTemperature(FA(address[1]));
  65.  
  66.           lcd.home(); lcd.clear();
  67.           lcd.setCursor(0, 0);
  68.           lcd.print(F("Zasilanie "));
  69.           lcd.print(temperature0);
  70.           lcd.print(F("C"));
  71.           lcd.setCursor(0, 1);
  72.           lcd.print(F("Powrot    "));
  73.           lcd.print(temperature1);
  74.           lcd.println(F("C"));
  75.           delay(5000);
  76.  
  77.     sensors.request();
  78.   }
  79. } // loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement