Hi, I’m just getting my feet wet in the world of Arduino and programming. I’m going to be installing an Arduino Uno into my Bunn coffee maker to regulate the water temperature (the temp switch in the coffee maker broke and there’s no replacement available). I’m using a 16x2 LCD as well to display current water temperature and temperature setpoint (which I’ll set using up and down buttons). The problem I’m having is programming in a dead zone for the temperature, so it won’t try to turn the heating element on and off a million times a minute trying to maintain a precise temperature.
I’m shooting for a temperature swing of 2 degrees. My first thought was this:
//thermostat code
if (settemp - 2 > temp) digitalWrite (heatout, HIGH);
if (settemp <= temp) digitalWrite (heatout, LOW);
The problem with that code is that it will end up just hovering somewhere around “settemp-2.” What I’d like it to do is this:
Let’s say the settemp is 200 degrees F. I’d like it to do nothing until the water temp (“temp”) falls to about 198 degrees F. Then I would like it to set the heatout pin to HIGH until it gets all the way up to 200, or settemp, then set heatout pin back to LOW.
Does anyone have any suggestions on how I can code this? ANY help would be amazing! Thanks in advance!