I'm pretty new about coding, I've read a lot of forum threads and tried for several days, but I can not get it to hold "maxtemp" until I press the reset button, max temp dropping with temp, and I need that continues to show what max temp has been
The button is connected to + 5V on one side and the other side has a 1k ohm resistor to 0V, and at the same legs as the button modstenden is connected to a wire to pin 13 on my Arduino uno.
#include <LiquidCrystal.h>
#include <max6675.h>
// setup termocupler
int thermoDO = 8;
int thermoCS_1 = 10;
int thermoCLK = 9;
MAX6675 thermocouple_1(thermoCLK, thermoCS_1, thermoDO);
float temp;
float maxtemp = 0;
// setup lcd
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
// setup button
const int buttonPin = 13;
int buttonState = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
lcd.begin(20, 4);
// wait for MAX chip to stabilize
delay(500);
pinMode(buttonPin,INPUT_PULLUP);
}
void loop() {
// Temp read
Serial.print("Sensor_1 temp = ");
Serial.println(thermocouple_1.readCelsius());
temp = thermocouple_1.readCelsius();
// Read maxtemp
if (temp > maxtemp) maxtemp = temp;
Serial.print("maxtemp = ");
Serial.println(maxtemp);
// Wright lcd
lcd.clear();
lcd.setCursor(0,0);
lcd.print("EGT Temp ");
lcd.print(temp);
lcd.setCursor(0,2);
lcd.print("MAX Temp ");
lcd.print(maxtemp);
delay(500);
//Button
buttonState = digitalRead(buttonPin);
if (buttonState == LOW) {
// reset maxtemp
maxtemp = 0;
}
}
Hope you guys can help me.