I'm trying to make a filling station for six bottles.
I build a system consisting of six valves and a big pump which is pressure operated by an internal mechanism so my arduino is not controlling the pump.
By pushing a button the corresponding valve opens and the bottle starts filling.
When the bottle is nearly full two wires circuit and the valve closes.
This last step is taking to long and after some research I can't figure out why...
When I monitor my code everything seems fine and the valve should close but it doesn't.
I tried altering my code so that releasing the button stops the valve and this works perfectly.
I think there is something wrong with the function analogread().
I'm getting a value of around 0,25 V when the liquid short circuits the wire.
Maybe the value is to low ?
anybody any suggestion ?
if ((digitalRead(bp1Valve)==LOW)&&((analogRead(ContactValve1))<25)){
digitalWrite(CommandValve1,HIGH);
Serial.println("Valve 1 open");
}
I don't have any delays in my code.
Thank you in advance !
You need to post your complete program and a diagram showing how things are connected.
You have not told us what you are trying to measure with analogRead().
If you just want an ON/OFF decision when liquid comes in contact with some wires why not use digitalRead(). Either way a lot depends on how things are connected - hence the need to see the diagram.
I used a project on instructables as example because I'm not experienced in electrical circuits.
The green and Red wires doesn't contain a button but are connected lose from each other.
When the liquid touches the wires they circuit and create a voltage.
Via analogRead() I read the signal and if it is higher than zero the bottle is full.
I rewrote the code to gain some experience in arduino programming.
But I also tried the code of the project but that didn't changed anything.
The project is not at my place but I'll post one as soon as I can.
And I used a TIP120 transistor.
But when I use the manual button and altered my code to stop filling when button was released, it worked quick enough. So I don't think the transistors are the problem ?
What is also strange is that when I monitor my code it says the valve is closed, but it didn't...
So I think the code works perfectly.
Also when I manualy short circuit the wire the valve works fine.
So could there be something wrong with the voltage or something ?
A simple pencil drawing is much easier to understand than a Fritzing diagram. And it would allow a proper indication of how the liquid is sensed rather than pretending it is a button.
Perhaps just do a detailed drawing to show how a single liquid sensor is connected.
I suggest you connect the red pin to 5v with a high value pullup resistor - perhaps 100k. Connect the blue wire directly to GND. Then you should be able to detect the water touching the probes using digitalRead()
Because water is poor conductor you need a high value pullup resistor. This arose in another Thread earlier today. And a pullup is better than a pulldown because it eliminates the risk of a short circuit.