Created
March 18, 2015 11:39
-
-
Save anonymous/56882d67190b56bc079b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "spark-dallas-temperature/spark-dallas-temperature.h" | |
#include "OneWire/OneWire.h" | |
#include "LiquidCrystal/LiquidCrystal.h" | |
#include "application.h" | |
#define ONE_WIRE_BUS D2 | |
OneWire oneWire(ONE_WIRE_BUS); | |
DallasTemperature sensor(&oneWire); | |
float temperature = 1.0; | |
char myStr[10]; | |
LiquidCrystal lcd(D0, D1, A5, D3, D4, D5); | |
void setup() { | |
//OneWire setup | |
//Spark.variable("read", &myStr, STRING); | |
sensor.begin(); | |
sensor.setResolution(12); | |
lcd.begin(20,4); | |
lcd.setCursor(0,0); | |
lcd.print("Hello, Sparky!"); | |
} | |
void loop() { | |
//Read and print temperature: | |
sensor.requestTemperatures(); | |
temperature = sensor.getTempCByIndex(0); | |
sprintf(myStr,"%.1f",temperature); | |
//sprintf(myStr,"%.3f",temperature); | |
lcd.setCursor(0,2); | |
String temp = String("Temp is: "); | |
temp = temp + myStr; | |
lcd.print(temp); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment