-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paththermistor.cpp
56 lines (48 loc) · 853 Bytes
/
thermistor.cpp
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
/*
*
*/
#include <Arduino.h>
#include <math.h>
#include "thermistor.h"
extern uint32_t MILLIS;
/*
*
*/
thermistor::thermistor(int sensorPinIn, int outputPinIn) {
sensorPin = sensorPinIn;
outputPin = outputPinIn;
thermThreshold = 0.1; // (V)
}
/*
*
*/
void thermistor::init(){
pinMode(sensorPin, INPUT_PULLUP);
pinMode(outputPin, OUTPUT);
}
/*
*
*/
void thermistor::loop(){
while(true){
checkCurrentValue();
if ((currThermVoltage - firstThermVoltage) > thermThreshold)
{
digitalWrite(outputPin, HIGH);
}
}
}
/*
*
*/
void thermistor::checkFirstValue(){
currThermValue = analogRead(sensorPin);
firstThermVoltage = currThermValue * (5.0 / 1023);
}
/*
*
*/
void thermistor::checkCurrentValue(){
currThermValue = analogRead(sensorPin);
currThermVoltage = currThermValue * (5.0 / 1023);
}