#include <LiquidCrystal.h>
double refV;
double tL=25;
double tH=tL+1;
const int button6 = 6; //this button brings temp up
const int button7 = 7; //this button brings temp down
const int button8 = 8;
int speakerPin=10;
int numTones = 5;
int tones[] = {261, 294, 330, 370, 415};
int button6state = 0;
int button7state = 0;
int button8state = 0;
LiquidCrystal lcd(12,11,5,4,3,2);
void setup(){
pinMode(button6, INPUT);
pinMode(button7, INPUT);
pinMode(button8, INPUT);
pinMode(10, OUTPUT);
pinMode(13,OUTPUT);
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print(tL);
lcd.print(" to ");
lcd.print(tH);
analogReference(DEFAULT);
refV=5;
Serial.begin(9600);
Serial.print("tL is: ");
Serial.print("\t");
Serial.println(tL);
Serial.print("tH is: ");
Serial.print("\t");
Serial.println(tH);
Serial.print("temp(C)");
Serial.print("\t");
Serial.println("status");
Serial.println("________________");
Serial.println("Beginning of Data: ");
}
void loop(){
int acc=0;
int N=10;
for(int i=0 ; i < N; i++) {
acc +=analogRead(0); delay(10);
}
double voltage= refV*acc/1023./(double(N));
double tempC=(voltage)*100.;
lcd.setCursor(0,1);
lcd.print(tempC);
button6state = digitalRead(button6); //code for button 6
if ( button6state == HIGH ){
tL = tL + 0.5;
tH = tH + 0.5;
lcd.setCursor(0,0);
lcd.print(tL);
lcd.print(" to ");
lcd.print(tH);
for(int i =0; i <numTones; i++){
tone(speakerPin, tones[4]);
delay(30)
}
noTone(speakerPin);
}
if(tH > 55){
for(int i =0; i<numTones; i++){
tone(speakerPin, tones[0]);
delay(100);
}
noTone(speakerPin);
tH = 55;
tL = 54;
for(int i = 0; i < 3 ; i++){
lcd.setCursor(9,0);
lcd.print(" ");
delay(300);
lcd.setCursor(9,0);
lcd.print(tH);
delay(300);
}
if(tL < 20){
for(int i =0; i<numTones; i++){
tone(speakerPin, tones[2]);
delay(100);
}
noTone(speakerPin);
tH = 21;
tL = 20;
for(int i = 0; i < 3 ; i++){
lcd.setCursor(0,0);
lcd.print(" ");
delay(300);
lcd.setCursor(0,0);
lcd.print(tL);
delay(300);
}
}
if (tempC<tL){
digitalWrite(13,HIGH);
}
if(digitalRead(13)==HIGH){
Serial.print(tempC);
Serial.print("\t");
Serial.println("1");
}
delay(50);
}