# Spa Temp Control

**URL:** <https://forum.arduino.cc/t/spa-temp-control/1017121>\
**Category:** General Guidance\
**Created:** [July 28, 2022, 5:41pm UTC](https://forum.arduino.cc/t/spa-temp-control/1017121 "2022-07-28T17:41:37Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ToddL1962](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/toddl1962/32/225060_2.png) [@ToddL1962](https://forum.arduino.cc/u/ToddL1962)\
**Post date:** [July 28, 2022, 5:46pm UTC](https://forum.arduino.cc/t/spa-temp-control/1017121/2 "2022-07-28T17:46:17Z")

</div>

> [@jordanc15](#):
>
> My goal right now is figuring out how I can make the pump turn on at 75 degrees but stay on for say 1 minute regardless of the water temp dropping below 75 which currently turns it off. I like that the water temp is constantly updating and if I add a delay to the else statement it slows down data collection on water temp which isn't how I would like it to work.

You will need to restructure your code using millis() to keep track of time rather than delay(). Also I think you would benefit from using a state machine and it would make it easy to add functionality later on as well.

Look at the following tutorials:

[State Machine](https://forum.arduino.cc/index.php?topic=604505.0)

[Example-code for timing based on millis()](https://forum.arduino.cc/t/example-code-for-timing-based-on-millis-easier-to-understand-through-the-use-of-example-numbers-avoiding-delay/974017)

---

_[View the full topic](https://forum.arduino.cc/t/spa-temp-control/1017121)._
