I’m new to arduino and am trying to put together a Heating and cooling system for and aquarium and I made a code and wanted to see if someone would please look it over and suggest any changes to the code or point out any problems. My main question is with the temperature settings, will they conflict or not, also will the chiller not turn on until the water reaches 79 or will it cycle on at anything >77? Here is the sketch below:
float tempC;
float tempF;
int tempPin = 0;
int ledPin = 13;
int ledPin2 = 12;
int relayPin = 11;
int relayPin2 = 10;
void setup()
{
Serial.begin(9600); //opens serial port, sets data rate to 9600 bps
pinMode (relayPin, OUTPUT);
pinMode (relayPin2, OUTPUT);
}
void loop()
{
tempC = analogRead(tempPin); //read the value from the sensor
tempC = (5.0 * tempC * 100.0)/1024.0; //convert the analog data to temperature
tempF = (tempC * 9)/ 5 + 32; // converts to fahrenheit
Serial.print ((int) tempC ); //send the data to the computer
Serial.print(" Celsius, ");
Serial.print ((int) tempF ); //send the data to the computer
Serial.print(" Fahrenheit, → ");
delay(1500); //wait 1.5 second before sending new data
digitalWrite(ledPin, HIGH); // sets the LED on
digitalWrite(ledPin2, HIGH);// sets LED 2 on
if (tempF > 79) digitalWrite(ledPin, HIGH); //sets chiller LED on
if (tempF > 79) digitalWrite(relayPin, HIGH); //Powers up chiller unit
if (tempF > 79) Serial.println (“Chiller On”);
if (tempF <= 77) digitalWrite(ledPin, LOW); //Turns off chiller LED
if (tempF <= 77) digitalWrite(relayPin, LOW); //Turn off power to unit
if (tempF <= 77) Serial.println (“Chiller Off”);
if (tempF <= 76) digitalWrite(ledPin2, HIGH); //turn heater LED on
if (tempF <= 76) digitalWrite(relayPin2, HIGH); //Turn Heater power on
if (tempF <= 76) Serial.println (“Heater On”);
if (tempF >= 77) digitalWrite(ledPin2, LOW); //Turn Heater LED off
if (tempF >= 77) digitalWrite(relayPin2, LOW); //Turn Heater power off
if (tempF >= 77) Serial.println (“Heater Off”);
}