#include "max6675.h" #include "LiquidCrystal_I2C.h" #include "Wire.h" #include "Keypad.h" LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); long setTemp = 0; long tempTol = 3; const byte numRows = 4; const byte numCols = 4; char keymap[numRows][numCols] = { {'1','2','3','A'}, {'4','5','6','B'}, {'7','8','9','C'}, {'*','0','#','D'} }; //letting arduino to identify pad bottons byte rowPins[numRows] = {9,8,7,6}; byte colPins[numCols] = {5,4,3,2}; int ktcSO = 11; int ktcCLK = 12; int ktcCS = A0; MAX6675 ktc(ktcCLK, ktcCS, ktcSO); Keypad keypad = Keypad( makeKeymap(keymap), rowPins, colPins, numRows, numCols ); char key = keypad.getKey(); void setup() { // put your setup code here, to run once: pinMode(10,OUTPUT); Serial.begin(9600); //Start serial lcd.begin(16,2); //Set the available spaces lcd.noAutoscroll(); lcd.setCursor(0,1); //Set the cursor to the next row lcd.print("Set (C):"); //This the temp. that was set lcd.setCursor(0,2); //Set the cursor to the next row lcd.print("Temp(C):"); //This is the current temp. lcd.setCursor(8,2); lcd.print(ktc.readCelsius()); } void loop() { // put your main code here, to run repeatedly: goto TempSetting; MainA:{ if (key = 'C') { lcd.setCursor(8,2); lcd.print(" "); digitalWrite(10,LOW); setTemp = 0; goto TempSetting; } else { if ((ktc.readCelsius()) > setTemp + tempTol) { digitalWrite(10,LOW); } else { if ((ktc.readCelsius()) < setTemp + tempTol) { digitalWrite(10,HIGH); } else { goto MainA; } } } } TempSetting:{ lcd.setCursor(8,2); lcd.print(ktc.readCelsius()); lcd.setCursor(8,1); switch(key) { case '0' ... '9': { delay(20); lcd.setCursor(8,1); setTemp = setTemp * 10 + (key); lcd.print(setTemp); break; } case 'A' : { lcd.setCursor(8,2); lcd.print(" "); lcd.setCursor(8,2); lcd.print(ktc.readCelsius()); delay(750); digitalWrite(10,HIGH); goto MainA; } } } }