fork(1) download
  1. #include <dht11.h>
  2.  
  3. #define dht_dpin 7
  4. dht11 DHT;
  5.  
  6. int light();
  7.  
  8. void setup() {
  9. Serial.begin(9600);
  10. }
  11.  
  12. void loop() {
  13.  
  14. //光照值-A1
  15. Serial.print("Light: ");
  16. Serial.println(light());
  17. //環境溫濕度-D7
  18. Serial.print("humidity: ");
  19. Serial.println(DHTt.humidity);
  20.  
  21.  
  22.  
  23. delay(1000);
  24. }
  25.  
  26. //光照感測器->A1
  27. int light()
  28. {
  29. int light = 0;
  30. light = analogRead(1);
  31. return light;
  32. }
  33.  
  34. typedef struct
  35. {
  36. int humidity;
  37. int temperature;
  38. }DHTdata_t;
  39.  
  40. DHTdata_t dht_data; //宣告一個名叫 DHTdata_t 的 dht_data 變數
  41.  
  42. DHTdata_t DHTt()
  43. {
  44. DHTdata_t tmp;
  45. DHT.read(dht_dpin);
  46. tmp.humidity = DHT.humidity;
  47. tmp.temperature = DHT.temperature;
  48. return tmp;
  49. }
  50.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:19: fatal error: dht11.h: No such file or directory
compilation terminated.
stdout
Standard output is empty