//源代码 #include <DigisparkOLED.h> #include <Wire.h> #include <dht.h> //From Rob Tillaart dht DHT11; #define DHT11PIN 4 void setup() { // put your setup code here, to run once: oled.begin(); } void loop() { oled.setCursor(20, 0); //左上方 oled.setFont(FONT8X16); oled.print(F("HUMITURE")); //将字符串包含到中f()以节省内存! oled.setFont(FONT6X8); oled.print(F(" HAI")); DHT11.read11(DHT11PIN); int h=DHT11.humidity; int t=DHT11.temperature; oled.setCursor(30, 3); //two rows down because the 8x16 font takes two rows of 8 oled.print(F("TEMP:")); oled.setCursor(62, 3); oled.println(t); oled.setCursor(75, 3); oled.println(" C"); oled.setCursor(30, 5); //two rows down because the 8x16 font takes two rows of 8 oled.print(F("HUMI:")); oled.setCursor(62, 5); oled.println(h); oled.setCursor(75, 5); oled.println(" %"); delay(1000); }