Facebook
From Abrupt Wolf, 3 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 344
  1. #include <LiquidCrystal.h>
  2. #include <OneWire.h>
  3. #include <DallasTemperature.h>
  4.  
  5. LiquidCrystal lcd(12, 11, 5,4,3,2);
  6.  
  7.  
  8. OneWire oneWire(1);
  9. DallasTemperature sensors(&oneWire);
  10.  
  11. unsigned long currentTime;
  12. unsigned long lastTime;
  13. unsigned long diffTime;
  14. float currentTemp;
  15. float minTemp = 0;
  16. float maxTemp = 0;
  17.  
  18.  
  19.  
  20. unsigned long lastTime1;
  21. unsigned long diffTime1;
  22. void setup() {
  23.  lcd.begin(16, 2);
  24.  sensors.begin();
  25.  minTemp = sensors.getTempCByIndex(0);
  26.  maxTemp = sensors.getTempCByIndex(0);
  27.  
  28. }
  29.  
  30. void loop() {
  31.  currentTime = millis();
  32.  diffTime = currentTime - lastTime;
  33.  diffTime1 = currentTime - lastTime1;
  34.  
  35.  
  36.  if(diffTime >= 10000UL){
  37.  
  38.  sensors.requestTemperatures();
  39.  float currentTemp = sensors.getTempCByIndex(0);
  40.  if(currentTemp > maxTemp){
  41.   maxTemp = currentTemp;
  42.  }else if(currentTemp < minTemp){
  43.   minTemp = currentTemp;
  44.  }
  45.  lastTime = currentTime;
  46.  
  47.  
  48.  lcd.clear();
  49.  lcd.setCursor(0,0);
  50.  lcd.print("aktualna temp: ");
  51.  lcd.setCursor(0,1);
  52.  lcd.print(currentTemp);
  53.  delay(6000);
  54.  
  55.  
  56.  lcd.clear();
  57.  lcd.setCursor(0,0);
  58.  lcd.print("minTemp: ");
  59.  lcd.print(minTemp);
  60.  lcd.setCursor(0,1);
  61.  lcd.print("maxTemp: ");
  62.  lcd.print(minTemp);
  63.  
  64.  }
  65.  
  66. }

Replies to Untitled rss

Title Name Language When
Re: Untitled Anorexic Mousedeer text 3 Months ago.
Re: Untitled Sweltering Hamerkop text 3 Months ago.