-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSPRINT_1_GROUP_PROJECT.ino
More file actions
62 lines (56 loc) · 1.48 KB
/
SPRINT_1_GROUP_PROJECT.ino
File metadata and controls
62 lines (56 loc) · 1.48 KB
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
55
56
57
58
59
60
61
62
/* */
//Libraries
#include <DHT.h>
//Constants
#define DHTPIN 7 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor for normal 16mhz Arduino
//Variables
float temp; //Stores temperature value
void setup()
{
Serial.begin(9600);
dht.begin();
pinMode(8, OUTPUT); //1,2,3,4 layers
pinMode(9, OUTPUT); //2,3,4 layers
pinMode(10, OUTPUT); //3,4 layers
pinMode(11, OUTPUT); //4 layers
}
void loop()
{
//Read data and store it to variables hum and temp
temp = dht.readTemperature();
//Print temp and humidity values to serial monitor
Serial.print("Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
if (temp >= 25)
{
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
}
else if (temp < 25 && temp >= 15)
{
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
}
else if (temp < 15 && temp >= 0)
{
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
}
else if (temp < 0)
{
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
}
delay(2000); //Delay 2 sec.
}