47 lines
1.0 KiB
C++
47 lines
1.0 KiB
C++
/*
|
|
|
|
|
|
|
|
*/
|
|
|
|
// include the library code:
|
|
#include <LiquidCrystal.h>
|
|
#include <OneWire.h>
|
|
#include <DallasTemperature.h>
|
|
|
|
// Data wire is conntec to the Arduino digital pin 4
|
|
#define ONE_WIRE_BUS 11
|
|
|
|
// Setup a oneWire instance to communicate with any OneWire devices
|
|
OneWire oneWire(ONE_WIRE_BUS);
|
|
|
|
// Pass our oneWire reference to Dallas Temperature sensor
|
|
DallasTemperature sensors(&oneWire);
|
|
|
|
|
|
|
|
// initialize the library by associating any needed LCD interface pin
|
|
// with the arduino pin number it is connected to
|
|
const int rs = 7, en = 6, d4 = 2, d5 = 3, d6 = 4, d7 = 5;
|
|
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
|
|
|
|
void setup() {
|
|
// set up the LCD's number of columns and rows:
|
|
lcd.begin(16, 2);
|
|
// Print a message to the LCD.
|
|
lcd.setCursor(0, 0);
|
|
lcd.print(" @ElectroPepper");
|
|
sensors.begin();
|
|
}
|
|
|
|
void loop() {
|
|
|
|
// Call sensors.requestTemperatures() to issue a global temperature and Requests to all devices on the bus
|
|
sensors.requestTemperatures();
|
|
|
|
|
|
lcd.setCursor(0, 1);
|
|
lcd.print(sensors.getTempCByIndex(0));
|
|
lcd.print("C");
|
|
}
|