DHT11错误编译板Arduino / Genuino Uno

时间:2017-09-07 00:17:02

标签: arduino

我遇到的问题是Arduino代码。这是一个名为Segment LED show temperature& amp;湿度。我使用的Arduino板是Uno Freaduino 2016板。连接到它是一个7段显示器,带有4个引脚:GND,CLK,DIO,VCC和温度和湿度传感器,用于引脚模拟0(A0)。

但是这部分很好,这是代码。我正在使用Arduino程序来编写它,但是有一个错误。

错误:

Arduino: 1.8.2 (Windows 10), Board: "Arduino/Genuino Uno"

E:\Code examples\Coding examples\Arduino\Segment_LED_Show_Temperatures_Humidity\Segment_LED_Show_Temperatures_Humidity.ino:3:19: fatal error: DHT11.h: No such file or directory

#include "DHT11.h"

       ^

compilation terminated.

exit status 1
Error compiling for board Arduino/Genuino Uno.

This report would have more information with
"Show verbose output during compilation"
 option enabled in File -> Preferences.

代码:

//variables
#include "DHT11.h"
#include "TM1637.h"
#define CLK4
#define DIO5
TM1637 tm1637(CLK, DIO);
DHT11 dht11(A0);

void setup() {
  tm1637.init();
  tm1637.set(BRIGHT_TYPICAL);
}

void loop() {
  dht11.start();
  tm1637.display(3,12);
  tm1637.display(2, (dht11.DHT11data)[2] % 10);
  tm1637.display(1, (dht11.DHT11data)[2] % 100 / 10);
  delay(1000);
  tm1637.clearDisplay();
  tm1637.display(3, (dht11.DHT11data)[0] % 10);
  tm1637.display(2, (dht11.DHT11data)[0] % 100 / 10);
  delay(1000);
}

1 个答案:

答案 0 :(得分:2)

错误:

#include "DHT11.h"

       ^

...表示找不到指定的.h文件。

也许您需要安装DHT11 Arduino driver package

如果正确安装了驱动程序包,那么该行应该是:

#include <dht11.h>