// Code for Projekt 1 = Uno + DS16B20 + 2x16 LCD // include the library code: #include <LiquidCrystal.h> #include <OneWire.h> #include <DallasTemperature.h> // initialize the library with the numbers of the interface pins LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // Data wire is plugged into pin 3 on the Arduino #define ONE_WIRE_BUS 6 // Setup a oneWire instance to communicate with any OneWire devices OneWire oneWire(ONE_WIRE_BUS); // Pass our oneWire reference to Dallas Temperature. DallasTemperature sensors(&oneWire); // Assign the addresses of your 1-Wire temp sensors. DeviceAddress inne = { 0x28, 0x34, 0x6F, 0xCE, 0x02, 0x00, 0x00, 0x32 }; DeviceAddress ute = { 0x28, 0x43, 0x79, 0xCE, 0x02, 0x00, 0x00, 0xCF }; void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // start serial port // Serial.begin(9600); // Start up the library sensors.begin(); // set the resolution to 10 bit (good enough?) sensors.setResolution(inne, 10); sensors.setResolution(ute, 10); } void printTemperature(DeviceAddress deviceAddress) { float tempC = sensors.getTempC(deviceAddress); if (tempC == -127.00) { lcd.print("Error getting temperature"); } else { lcd.print("C "); lcd.print(tempC); // Serial.print(" F: "); // Serial.print(DallasTemperature::toFahrenheit(tempC)); } } void loop() { sensors.requestTemperatures(); // Print to the LCD. delay(4000); lcd.setCursor(0, 0); lcd.print("Utomhus "); lcd.setCursor(9, 0); printTemperature(ute); lcd.setCursor(0, 1); lcd.print("Inomhus "); lcd.setCursor(9, 1); printTemperature(inne); delay(7000); lcd.setCursor(0, 0); lcd.print("Arduino Proj. 1 "); lcd.setCursor(0, 1); lcd.print("(c)Goran.L 2015 "); delay(3000); lcd.setCursor(0, 0); lcd.print("VAT'A MISSTEIKA "); lcd.setCursor(0, 1); lcd.print(" TO MEJKA "); }