const float BETA = 3950; // should match the Beta Coefficient of the thermistor
const int wyjscie = 27;
const int wej100 = 13;
const int wej90 = 12;
const int wej80 = 14;
const int d1 = 23;
const int d2 = 22;
const int d3 = 21;
float celsius;
float temp100 = 70;
float temp90 = 60;
float temp80 = 50;
int grzanie = 0;
void setup() {
Serial.begin(9600);
pinMode(wej100, OUTPUT);
pinMode(wej90, OUTPUT);
pinMode(wej80, OUTPUT);
pinMode(wyjscie, OUTPUT);
pinMode(d1, OUTPUT);
pinMode(d2, OUTPUT);
pinMode(d3, OUTPUT);
}
void loop() {
if (digitalRead(wej100)==HIGH){
grzanie = 1;
Serial.println("grzanie 100");
}
if (digitalRead(wej90)==HIGH){
grzanie = 2;
Serial.println("grzanie 90");
}
if (digitalRead(wej80)==HIGH){
grzanie = 3;
Serial.println("grzanie 80");
}
int analogValue = analogRead(2);
celsius = 1 / (log(1 / (4096. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
Serial.print("Temperature: ");
Serial.print(celsius);
Serial.println(" ℃");
delay(1000);
//diody do pokazania temperatury
if (celsius>temp100){
digitalWrite(d1, HIGH);
}
if (celsius>temp90){
digitalWrite(d2, HIGH);
}
if (celsius>temp80){
digitalWrite(d3, HIGH);
}
if (celsius<temp100){
digitalWrite(d1, LOW);
}
if (celsius<temp90){
digitalWrite(d2, LOW);
}
if (celsius<temp80){
digitalWrite(d3, LOW);
}
switch (grzanie) {
case 1:
if (celsius<temp100){
digitalWrite(wyjscie, HIGH);
}
break;
case 2:
if (celsius<temp90){
digitalWrite(wyjscie, HIGH);
}
break;
case 3:
if (celsius<temp80){
digitalWrite(wyjscie, HIGH);
}
break;
}
if ((celsius > temp100)&&(grzanie == 1)){
digitalWrite(wyjscie,LOW);
grzanie= 0;
}
if ((celsius > temp90)&&(grzanie == 2)){
digitalWrite(wyjscie,LOW);
grzanie= 0;
}
if ((celsius > temp80)&&(grzanie == 3)){
digitalWrite(wyjscie,LOW);
grzanie= 0;
}
}