-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTripleSensorArray.ino
More file actions
66 lines (58 loc) · 1.42 KB
/
TripleSensorArray.ino
File metadata and controls
66 lines (58 loc) · 1.42 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
63
64
65
#include <math.h>
int sensorPin = A1;
int sensorPinTwo = A2;
int sensorPinThree = A3;
int lightPin = 12;
int tempLightPin = 11;
int tempLightPinTwo = 13;
int data;
int dataTwo;
int bleet = 10;
int tempTwo;
int voltage;
double Thermistor(int RawADC) {
double Temp;
Temp = log(10000.0*((1024.0/RawADC-1)));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp)) * Temp);
Temp = Temp - 273.15;
Temp = (Temp * 9.0)/ 5.0 + 32.0;
return Temp;
}
void setup(){
Serial.begin(9600);
pinMode(lightPin, OUTPUT);
pinMode(tempLightPin, OUTPUT);
pinMode(tempLightPinTwo, OUTPUT);
pinMode(bleet, OUTPUT);
digitalWrite(bleet, HIGH);
}
void loop(){
int readVal=analogRead(sensorPin);
double temp = Thermistor(readVal);
Serial.print("Temperature: ");Serial.print(temp);Serial.println("F");
if (temp > 75){
digitalWrite(tempLightPin, HIGH);
}
else{
digitalWrite(tempLightPin, LOW);
}
data = analogRead(sensorPinTwo);
Serial.print("Light: ");Serial.println(data);
if (data < 200){
digitalWrite(lightPin, HIGH);
}
else{
digitalWrite(lightPin, LOW);
}
dataTwo = analogRead(sensorPinThree);
float voltage = (dataTwo/1024.0) * 5.0;
float tempTwo = (voltage - 0.5) * 100;
Serial.print("Temperature 2: ");Serial.print(tempTwo);Serial.println("C");
if (tempTwo > 21){
digitalWrite(tempLightPinTwo, HIGH);
}
else{
digitalWrite(tempLightPinTwo, LOW);
}
delay (500);
}