mpmcws

LCD + DS18B20

Jul 15th, 2018
40
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //LCD (no I2C) con DS18B20
  2. //Tolentino Codesta - Cerani luglio 2018
  3. #include <LiquidCrystal.h> // libreria
  4. #include <cactus_io_DS18B20.h> // libreria
  5. #define DS18B20_Pin  9 // pin
  6. DS18B20 ds(DS18B20_Pin); //istanza
  7. float celsius; // variabile
  8. const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
  9. LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
  10. void setup() {
  11.   lcd.begin(16, 2); // LCD ha 16 caratteri e 2 linee
  12. }
  13. void loop() {
  14.   ds.readSensor();
  15.   celsius = ds.getTemperature_C();
  16.   lcd.setCursor(0, 1); //riposiziono il cursore
  17.   lcd.print(celsius);
  18.   lcd.print((char)223);
  19.   lcd.print("C");
  20. }
RAW Paste Data