int ThermistorPin = 0;
int Vo;
const int Pot = 1;
int sensorValue1 = 0;
int outputValue1 = 0;
const int Pot2 = 2;
int sensorValue2 = 0;
int outputValue2 = 0;
const int ledPin = 2;
float R1 = 10000;
float logR2, R2, T;
float c1 = 1.009249522e-03, c2 = 2.378405444e-04, c3 = 2.019202697e-07;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
Vo = analogRead(ThermistorPin);
R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
T = (1.0 / (c1 + c2*logR2 + c3*logR2*logR2*logR2));
T = T - 273.15;
T = (T * 9.0)/ 5.0 + 32.0;
sensorValue1 = analogRead(Pot); //gets pot valve
outputValue1 = map(sensorValue1, 0, 1023, 0, 1023);
sensorValue2 = analogRead(Pot2); //gets pot2 valve
outputValue2 = map(sensorValue2, 0, 1023, 0, 1023);
int ThermistorPin = analogRead(Vo); //sets valve to turn on led (output)
if (Vo > outputValue1) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
Serial.print("Pot1: ");
Serial.print(outputValue1);
Serial.print(", Pot2: ");
Serial.print(outputValue2);
Serial.print(", Temperature: ");
Serial.print(T);
Serial.print(" °F");
Serial.print(", Raw ");
Serial.print(Vo);
Serial.println();
delay(500);
}