程式碼如下
/*
* SHT-15 - 4
*/
#include <SHT1x.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd( 7, 8, 9, 10, 11, 12 );
SHT1x sht1x( 6, 5 );
void setup() {
lcd.begin( 16, 2 );
lcd.print( "SHT-15 - 4" );
Serial.begin( 9600 );
}
String getWeather() {
float temp_c, temp_f, humidity;
String result = "";
temp_c = sht1x.readTemperatureC();
temp_f = sht1x.readTemperatureF();
humidity = sht1x.readHumidity();
result.concat( (long) temp_c );
result += "C,";
result.concat( (long) temp_f );
result += "F,";
result.concat( (long) humidity );
result += "%";
return result;
}
void loop() {
lcd.setCursor( 0, 1 );
lcd.print( getWeather() );
Serial.println( "Running..." );
delay( 1000 );
}


























