Hello everybody ,
I want to do a automatic temp / fan controller for my PC. I know that the output from motorshield is only ~10.4v max with 12v due h-bridge but i’m gonna supply it with ~15v after everything is running.
i have a problem with my code, the fan don’t react with the temp and why the thermistor is sooo unaccuarte?
I’m working in this project with arduino uno R3, motorshield and LCD 16x2.
This is the code :
#include <LiquidCrystal.h>
#include <math.h>
LiquidCrystal lcd(6,5,4,2,1,0);
int tempMin = 10;
int tempMax = 20;
int fanSpeed;
int fanLCD;
int temp;
int val;
int fan = 3;
void setup() {
digitalWrite(12, HIGH);
digitalWrite(9, LOW);
lcd.begin(16,2);
}
double Thermister(int RawADC) {
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15;
return Temp;
}
void loop() {
if(temp < tempMin) {fanSpeed = 0;analogWrite(fan,0);}
if((temp >= tempMin) && (temp <= tempMax)){
fanSpeed = map(temp, tempMin, tempMax, 32, 255);
fanLCD = map(temp, tempMin, tempMax, 0, 100);
analogWrite(fan, fanSpeed);}
{double temp;
val=analogRead(2);
temp=Thermister(val);
lcd.print("Temp: ");
lcd.print(temp);
lcd.print("C ");
lcd.setCursor(0,1);
lcd.print(“FANS: “);
lcd.print(fanLCD);
lcd.print(”%”);
delay(2000);
lcd.clear();}
}
Thanks a lot!!!