So I am trying to find/write a code that can turn a solenoid ball valve on/off when a hall effect sensor comes in contact with a magnet.
So in general I have a 55 gallon tank with a solenoid driven ball valve at the bottom, a consistant supply of water coming in, a hall effect sensor at the top of the tank and one at the bottom enclosed in a PVC tube with a floating magnet ring surrounding them. When the water raises and lifts the floating magnet to the same level as the top hall effect sensor. The solenoid is then activated and the ball valve get switched open until enough water is released that the bottom hall effect sensor is activated which sends a signal to the solenoid to close.
The kicker is that I have 10 of these tanks.... and I would like to hook them all up through 1 arduino MEGA.
Is there anyone out there who would know how to write this code or help me figure it out? I am willing to compensate for your time if I cant find out how to code it myself.
This sounds like a candidate for writing a "WaterTank" class. That way you're only writing the code for one tank, and re-using it very simply for as many tanks as you like.
The way I see it there's 3 pins involved in a tank - high water, low water and valve.
Your class could have a simple state variable with 4 states - full, emptying, empty, filling.
The hall effect sensors would switch between states (filling->full, and emptying->empty), and you also switch states when you open or close the valve (full->emptying, empty->filling)
The three pin numbers would form the parameters of the class constructor, and then you'd just create 10 instances of it with different pin numbers.
Actually, you can do it with just 2 states, as the two in-between states are merely implied states.
And, just to prove how easy it is, and just how great I am ( 8)) I have knocked up a quick "Toggle" library that should do what you want. When input A goes low it turns on the output, when input B goes low it turns off the output.
Also useful for a million and one other situations besides a urinal flushing system.