In this video lesson we introduce the concept of Arduino Arrays, and illustrate by writing a simple program which inputs and prints a list of grades. The code from the video above is presented below for your convenience.
In this video lesson we show you how to measure temperature and humidity using the DHT11 sensor. For your convenience, we include the code below which we develop in the above video. Enjoy!
Arduino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <DHT.h>
#define DHTPIN 11
#define DHTTYPE DHT11
DHTmyDHT(DHTPIN,DHTTYPE);
intbr=115200;
intsetUpDelay=1000;
intmeasDelay=1000;
floattempC;
floattempF;
floathum;
floatHIF;
floatHIC;
Stringmessage;
voidsetup(){
// put your setup code here, to run once:
Serial.begin(br);
myDHT.begin();
delay(setUpDelay);
}
voidloop(){
// put your main code here, to run repeatedly:
tempC=myDHT.readTemperature(false);
tempF=myDHT.readTemperature(true);
hum=myDHT.readHumidity();
if(isnan(tempC)||isnan(tempF)||isnan(hum)){
Serial.println("Failed to Read Data on DHT11");
return;
}
HIC=myDHT.computeHeatIndex(tempC,hum,false);
HIF=myDHT.computeHeatIndex(tempF,hum,true);
message="Temp: "+String(tempC)+" deg C "+String(tempF)+" deg F Humidity: "+String(hum)+" % Heat Index: "+String(HIC)+" deg C "+String(HIF)+" deg F.";
Serial.println(message);
// Serial.print("Temp: ");
// Serial.print(tempC);
// Serial.print(" deg C ");
// Serial.print(tempF);
// Serial.print(" deg F ");
// Serial.print("Humidity: ");
// Serial.print(hum);
// Serial.print(" % ");
// Serial.print("Heat Index: ");
// Serial.print(HIC);
// Serial.print(" deg C ");
// Serial.print(HIF);
// Serial.println(" deg F ");
delay(measDelay);
}
Making The World a Better Place One High Tech Project at a Time. Enjoy!