Problem with logic behind my code

Hey guys, I have a kinda weird question. Im trying to write a simple program that turns a pump on once the pressure gets below 40psi, it then needs to pump the presure up to 60 psi and then stop, waiting for the presure to go back down to 40 psi where it will kick back on. Ive made my brain hurt for the past hour trying to figure out what logic statments to use to make this work, any ideas?

Pseudo code:

If pressure > 60
turn pump off

else if pump < 40
turn pump on

Best that I can do with the current information.

Let us see your best effort at the code. Read the forum guidelines to see how to properly post code and some good information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Post a wiring diagram, please.

1 Like

Use the constrain() function to design a 2-point controller.

Have a nice day and enjoy coding in C++.

bro you have no idea how many things i tried, i just tried this out and it worked thank you so much. After writting the post i was able to find another solution of doing the following but this is much more ellegant, thanks

if < 40
while less then 60
turn on
else off

the only problem with this is I couldnt have a loop running while the program was since im using a esp nodemcu and i need to see the pressure wirelessly, thanks again for the help!

so of course you're stuck in this while loop

why aren't you doing what @groundFungus suggested ???

So its NOT so simple.

show us your code and we will be able to help you fit the pump management into it.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.