I am trying to read water tank water level but i stuck with the code its showing some time right and some time wrong value
can any one help me where am i wrong
thanks
What sensors are you using on the tank (link please) to measure the levels. I suspect the problem is floating pins and this can maybe be solved with wiring the sensors differently (depending on what type they are) and flipping the code logic or adding pull down resistors to prevent the pins from floating.
Riva:
What sensors are you using on the tank (link please) to measure the levels. I suspect the problem is floating pins and this can maybe be solved with wiring the sensors differently (depending on what type they are) and flipping the code logic or adding pull down resistors to prevent the pins from floating.
UKHeliBob:
What are you using to sense the water level and what is holding the inputs at a known state all of the time ?
UKHeliBob:
floating pins/water level sensor
I like the sound of that
i am just using digital pins of arduino no any other sensor any nothing is holding the inputs at a known state all of the time
nothing is holding the inputs at a known state all of the time
That is almost certainly the cause of the problem. The inputs could be at any state, HIGH or LOW, when not in contact with the water
A suggestion : Change the pinMode() of the inputs to INPUT_PULLUP to activate the built in pullup resistors so that they are held HIGH unless in contact with the water. When in contact with the water arrange the circuit so that the pins are connected to GND. In the program change the logic to test for the inputs being HIGH to indicate that they are out of the water. Do not write to the pins in the program
UKHeliBob:
That is almost certainly the cause of the problem. The inputs could be at any state, HIGH or LOW, when not in contact with the water
A suggestion : Change the pinMode() of the inputs to INPUT_PULLUP to activate the built in pullup resistors so that they are held HIGH unless in contact with the water. When in contact with the water arrange the circuit so that the pins are connected to GND. In the program change the logic to test for the inputs being HIGH to indicate that they are out of the water. Do not write to the pins in the program