Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Program odczytuje temperaturę z czujnika
- #include <OneWire.h>
- #include <DS18B20.h>
- #include <LiquidCrystal_I2C.h>
- // Numer pinu do którego podłaczasz czujnik
- #define ONEWIRE_PIN 2
- LiquidCrystal_I2C lcd(0x3f, 16,2);
- // Adres czujnika
- byte address[8] = {0x28, 0xFF, 0xE3, 0xE1, 0x85, 0x16, 0x3, 0xE9};
- OneWire onewire(ONEWIRE_PIN);
- DS18B20 sensors(&onewire);
- void setup() {
- while(!Serial);
- Serial.begin(9600);
- sensors.begin();
- sensors.request(address);
- lcd.begin(16,2);
- lcd.init();
- lcd.backlight();
- }
- void loop() {
- if (sensors.available())
- {
- lcd.clear();
- float temperature = sensors.readTemperature(address);
- Serial.print(temperature);
- Serial.println(F(" 'C"));
- lcd.setCursor(1,0);
- lcd.print("Temperatura: ");
- lcd.setCursor(0,1);
- lcd.print(temperature);
- lcd.print("*C");
- sensors.request(address);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment