Untitled

 avatar
unknown
plain_text
a year ago
824 B
6
Indexable
#include <microDS18B20.h>
#include <LCD_I2C.h>
MicroDS18B20<27> sensor;
uint8_t address[8];
 
 
LCD_I2C lcd(0x27, 16, 2);
 
byte stopnie[8] = {
  0b00110,
  0b01001,
  0b01001,
  0b00110,
  0b00000,
  0b00000,
  0b00000,
  0b00000
};
 
 
void setup() {
  Serial.begin(9600);
 
  lcd.begin();
  lcd.backlight();
  lcd.createChar(0, stopnie);
 
}
 
void loop() {
 
  lcd.setCursor(0, 0);
  static uint32_t tmr;
  if (millis() - tmr >= 800) {
    tmr = millis();
 
    if (sensor.readTemp()) {
      lcd.print(sensor.getTemp());
      lcd.write(byte(0));
      lcd.print('C');
    } else Serial.println("error");
 
    sensor.requestTemp();
  }
 
  delay(1000);
  lcd.clear();
 
 
  lcd.setCursor(0, 1);
  if (sensor.readAddress(address)) {
    for (uint8_t i = 1; i < 10; i++) {
      lcd.print(address[i], HEX);
    }
  }
 
}
Editor is loading...
Leave a Comment