#include #define THERMISTOR_1_PIN 2 #define NUMTEMPS1 20 LiquidCrystal lcd(2, 3, 4, 5, 6, 7); byte degr[8] = { 0b01110, 0b10001, 0b10001, 0b01110, 0b00000, 0b00000, 0b00000, 0b00000 }; int hysteresis = 0; int pot1 = 0; short temptable1[NUMTEMPS1][2] = { {1, 841}, {54, 255}, {107, 209}, {160, 184}, {213, 166}, {266, 153}, {319, 142}, {372, 132}, {425, 124}, {478, 116}, {531, 108}, {584, 101}, {637, 93}, {690, 86}, {743, 78}, {796, 70}, {849, 61}, {902, 50}, {955, 34}, {1008, 3} }; void setup() { Serial.begin(9600); pinMode(9, OUTPUT); pinMode(8,OUTPUT); lcd.createChar(0, degr); lcd.begin(16, 2); } void loop() { pot1 = analogRead(A5); pot1 = map(pot1, 0, 1023, 0, 255); hysteresis = analogRead(A4); hysteresis = map(hysteresis, 0, 1023, 0, 9); int rawvalue1 = analogRead(THERMISTOR_1_PIN); int celsius1 = read_temp1(); int fahrenheit1 = (((celsius1 * 9) / 5) + 32); Serial.print("Current temp1: "); Serial.print(celsius1); Serial.print("C / "); Serial.print(fahrenheit1); Serial.println("F"); Serial.print("Raw value1: "); Serial.println(rawvalue1); Serial.println(" "); lcd.setCursor(0,0); lcd.print("Now: "); lcd.print(celsius1); lcd.print ((char)0); lcd.print("C"); lcd.setCursor(14,0); lcd.print("H"); lcd.print (hysteresis); lcd.setCursor(0,1); lcd.print("Set to: "); lcd.print(pot1); lcd.print ((char)0); lcd.print("C"); delay(50); if (pot1 < 100){ lcd.setCursor(12,1); lcd.print(" "); } else{} if (pot1 < 10){ lcd.setCursor(11,1); lcd.print(" "); } else{} if (celsius1 < 100){ lcd.setCursor(9,0); lcd.print(" "); } else{} if (celsius1 < 10){ lcd.setCursor(8,0); lcd.print(" "); } else{} if (pot1 > celsius1 + (hysteresis/2)){ digitalWrite(8,HIGH); } else{} if (pot1 < celsius1 - (hysteresis/2)){ digitalWrite(8,LOW); } else{} } int read_temp1() { int rawtemp1 = analogRead(THERMISTOR_1_PIN); int current_celsius1 = 0; byte i; for (i=1; i rawtemp1) { int realtemp1 = temptable1[i-1][1] + (rawtemp1 - temptable1[i-1][0]) * (temptable1[i][1] - temptable1[i-1][1]) / (temptable1[i][0] - temptable1[i-1][0]); if (realtemp1 > 255) realtemp1 = 255; current_celsius1 = realtemp1; break; } } if (i == NUMTEMPS1) current_celsius1 = 0; return current_celsius1; }