I wanting to upgrade my spring water treatment system for my house. The way the system works now is spring water is constantly being filtered and sterilized then dumped into a 1,600 gallon tank. As the tank fills up the water overflows out a drain. What I'm wanting to do is have the tank completely filled then a solenoid shut off the water till the level drops below say %50 and then open the solenoid to fill it again.

I have a 7-seg water level indicator driven by a nano and ultrasonic Rx/Tx that's on the tank now and works great. I just have no idea how to set a output to come on till some point and then stay off till some other point.

urm i dont knw if the return is in analog value or digital value but my example should apply to your application what so everok first you should know how high the water is now,then you need to set how high the water should be at its highest then you should set how low the water could be b4 the water should be filling in to the tank

then it would be as a simple as(return digital Value) if (WaterNow==SetHighPoint)then shut valve;if (WaterNow==SetLowPoint)then open valve;

(return analog value)if (WaterNow(what analog value that you get for the sensor) is >= SetHighPoint(this is where you set the value of max water level)then shut valve ;if (WaterNow is <= SetLowPoint(set the minimum value of water) ) then open valve;

Use >= and <= tests, not ==. Otherwise you may miss the crucial measurement and drain your cistern. Make sure that the set points are far enough apart that the solenoid isn't in any danger of being rapidly cycled - although it sounds like you already have this under control.

As a side issue, when it comes to important stuff like flooding etc. you should have a backup circuit.Something like a float/limit switch independant of your controller.It would provide a cutoff to the filling of the tank at an extreme level.

The way you have it in your schematic isn't the same as how you have it wired up!

What I'm wanting to do is have the tank completely filled then a solenoid shut off the water till the level drops below say %50 and then open the solenoid to fill it again.

Surely a float valve with some hysteresis is all you need here? I don't see any need for it to be controlled electrically never mind electronically, from what you've described so far.

There is two reasons why it's electric/electronic. One reason is I have a solenoid in the water circuit so if i loose power for some reason or the UV bulb burns out it will cut the water off filling the tank. I have a photo cell in the UV filter housing if the bulb goes out the water gets cut if not I'm dumping unsanitized water into my tank. The other reason it's electronic is the tank is in a water shed 80 yards up over the house on the hill. In the summer time when it's dry and the spring not producing good or not at all. I have to walk up and check it every day but with the 7 seg display I can just look up and see what the tank level is. If it gets low I have to start haling it in.