#include
LiquidCrystal lcd(7,6,5,4,3,2);
float temp;
int tempPin = A0; //arduino pin used for temperature sensor
int tempMin = 25; // the temperature to start the buzzer
int tempMax = 70;
int fan = 6; // the pin where fan is connected
int fanSpeed = 0;
int fanLCD;
void setup() {
pinMode(fan, OUTPUT);
pinMode(tempPin, INPUT);
[Link](16,4);
}
void loop() {
temp = analogRead(tempPin);
temp = (temp *5.0*100.0)/1024.0; //calculate the temperature in Celsius
delay(1000); // delay in between reads for stability
if(temp < tempMin) { // if temp is lower than minimum temp
fanSpeed = 0; // fan is not spinning
digitalWrite(fan, LOW);
}
if((temp >= tempMin) && (temp <= tempMax)) //if temperature is higher than the
minimum range
{
fanSpeed = map(temp, tempMin, tempMax, 32, 255); // the actual speed of fan
analogWrite(fan, fanSpeed); // spin the fan at the fanSpeed speed
}
[Link]("TEMP: ");
[Link](temp);
// display the temperature
[Link]("C ");
[Link](0,1); // move cursor to next line
[Link]("FANS: ");
[Link](fanLCD);
// display the fan speed
[Link]("%");
delay(200);
[Link]();
}
int readTemp() { // get the temperature and convert it to celsius
temp = analogRead(tempPin);
return temp * 0.48828125;
}