#include "max6675.h"
#include <LiquidCrystal.h>
const int motor = 13;
const int LedRed = 12;
const int LedGreen = 11;
int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
void setup() {
// put your setup code here, to run once:
// setup - LCD
// set up the LCD's number of columns and rows:
Serial.begin(9600);
lcd.begin(16, 2);
lcd.print("Automated Plant");
lcd.setCursor(0,1);
lcd.print("Watering System!");
pinMode(motor, OUTPUT);
pinMode(LedRed, OUTPUT);
pinMode(LedGreen, OUTPUT);
delay(2000);
lcd.clear();
lcd.print("Temp= ");
lcd.setCursor(0,1);
lcd.print("WaterPump= ON");
delay(500);
}
void loop() {
// basic readout test, just print the current temp
Serial.print("C = ");
Serial.println(thermocouple.readCelsius());
// For the MAX6675 to update, you must delay AT LEAST 250ms between reads!
int value = analogRead(0);
float Temperature = ( 5.0 * value* 100.0) / 1024.0;
lcd.setCursor(6,0);
lcd.print(Temperature);
lcd.setCursor(11,1);
if (Temperature > 42){
digitalWrite(motor, HIGH);
digitalWrite(LedRed, HIGH);
digitalWrite(LedGreen, LOW);
lcd.print("ON ");
}
else {
digitalWrite(motor, LOW);
digitalWrite(LedRed, LOW);
digitalWrite(LedGreen, HIGH);
lcd.print("OFF");
}
delay(1000);
}