I'm trying to read a pressure switch/Sensor in order to use it to stop a solenoid valve.
So the valve starts pumping and when the pressure switchs triggers then the valve will stop.
I'm using an analogic pressure switch(image below) and I'm not sure if that's how it works (also I've heard about the multitask on Arduino and maybe that's the problem so it can't read the pressure switch while it's pumping) I would appreciate any kind of help.
const int mtr = 22;
const int va = 23;
const int sensor = 24;
void setup() {
pinMode(mtr, OUTPUT);
pinMode(va, OUTPUT);
pinMode(sensor, INPUT);
}
void loop() {
do{
digitalWrite(va, HIGH);}
while(digitalRead(sensor==HIGH);
digitalWrite(va, LOW);
}
digitalWrite(mtr, HIGH);
delay(1000);
digitalWrite(mtr,LOW);
}
Valve starts pumping
2.The sensor triggers because of the pressure generated by the valve on a recipient
3.After the sensor is triggered the valve stops pumping.
4.The motor starts and then stops
(This is like the first script, it will be larger and the delays will be removed for now I just want the valve on a on or off state depending on the pressure and the sensor)
Actually the system is a washing machine, so the pressure switch is connected to the Arduino and connected through a house that is in the washing machine. So the valve starts the flow and when the pressure switch triggers then the valve should stop the flow. Thanks Tom
Yeah, so I think it is a language mistake here there's no 'pump' all the time I was referring to a valve (I will eventually add the pump but I think it will be the same problem as the valve since I need to understand the pressure switch)
I was investigating and found the 'external interruptions' functions. So it will read the pressure switch state all the time and identify when there is a change on the state of it (like in a button). So starts flowing water and all the time checks if there's a status change on the pressure switch and when the pressure triggers because of the pressure then will stop the flow. Something like
and then the 'void flow()' is just a "digitalWrite(valve, LOW)" instruction that executes when the pressure switch triggers (it think the pressure switch works in the same way as a button, it just connect two plates through a pulse)
So it is a pressure switch for a front loading washing machine.
Do you know the pinout for the switch, is it one switch or two switches.
Do you know how to fit it to a machine and have you tried to see what its output does with water pressure from the depth of the machine?
What is the voltage of the valve solenoid and do you have a power supply for it and any data or specifications?
Before going to code, you have to make sure you hardware is suitable for the job and will provide the correct inputs ti the controller, as well as any outputs and how they will control your valve etc?