I have 2 Over head tank in my house and each will be controlled by a 230V solenoid valve. There are 2 float switches in each of the tank. The float switches are being connected to arduino using pullup with 36ft 1sq.mm wire along with all the household appliances line concealed. Whenever the tank water is reduced, the motor turns on, but suddenly it turns off in the middle of the filling the water and when i reset the arduino, it works like crazy and i dont know what happened. After several resets, the arduino seems to work as normal.
I think this is interference problem but i don't know exactly what is the proble.
I have uploaded my code if any mistakes please notify me.
I have also uploaded the float switch i am using it is normally open switch.
The diameter of the wire is irrelevant, and I already saw the use of internal pull up in your code.
Internal (weak) pull up is ok for short wiring to a breadboard, but 36ft is like a big aerial.
It picks up lots of interference that you have to kill.
Try adding a 1k pull up resistor (you can leave the code as it is), and the capacitor I mentioned in post#1.
Leo..
Wawa:
The diameter of the wire is irrelevant, and I already saw the use of internal pull up in your code.
Internal (weak) pull up is ok for short wiring to a breadboard, but 36ft is like a big aerial.
It picks up lots of interference that you have to kill.
Try adding a 1k pull up resistor (you can leave the code as it is), and the capacitor I mentioned in post#1.
Leo..
I Will definitely try that and can i use interrupts instead of normal method of sensing the input? Will it be effective than the previous method i tried?
Interrupts will be less effective. They are intended to respond quickly to small glitches - exactly the stuff you are trying to remove. Interrupts are also more complex to visualize and unnecessary for the data you are working with here.
Can i use a 22micro farad electrolytic cap. If not then can anyone please say why because these cap can be used as a bypass cap as mentioned in the wiki.
PS - if i am wrong dont mistake me as i am a newbie. Thank you.