having hard time figure out what type of statement id use for what im trying to accomplish.
basically:
pot1 value needs to turn on led based on val1 (which i have working with an if statement)
pot2 value needs to keep the led on till Val1 is below the value of pot2
not sure if this makes sense but im trying to build a fan controller that will hit a temp higher than the off temp value and then run till it hits that off temp value.
note: delay is there just to slow down sketch
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("Pot: ");
Serial.print(outputValue1);
Serial.print("Pot2: ");
Serial.print(outputValue2);
Serial.print("Temperature: ");
Serial.print(T);
Serial.println(" F");
Serial.print("Raw ");
Serial.print(Vo);
delay(500);
}
Pot 1 gives the desired value.
Pot 2 sets the maximum allowed value. Right?
not sure if this makes sense but im trying to build a fan controller that will hit a temp higher than the off temp value and then run till it hits that off temp value.
Not exactly.
Can You try using an other explanation? Pot 2 is max and Pot 1 is the desired value.
The writing about over temperature I don't understand.
It would be easier if you have fixed temperatures in the sketch.
Potentiometer 1 sets the high temperature, to turn on the fan when it gets too hot.
Potentiometer 2 sets the low temperature, when the fan can be turned off.
What should happen when potentiometer 2 is set higher than potentiometer 1 ? I suggest to keep the fan on for safety and turn the fan off when the temperature is below both potentiometers.
I would like to add a variable that tells if the fan is on or off. It is not needed, but I think the sketch will be better.
if( temperature > high_temperature_setting)
{
if fan is not on, then turn on the fan
}
else if( temperature < low_temperature_setting && temperature < high_temperature_setting)
{
if fan is not off, then turn off the fan
}
I'm looking to have this project be fully programming without a pc. It's gona have a display and hopefully store the values in the eeprom so they're saved when power is cut