Hi all,
I am new to Arduino.
I am trying to code a program with a liquid level sensor controlled by a toggle switch. So if the liquid is low a buzzer will alarm.There is an LCD showing the state of sensor.and LEDs showing state of sensor. If the switch is low LCD should display bypassed and only blue Led should lit. If liquid level is good geen Led should lit and LCD display Monitoring.
But my code is broke somewhere. It loops around lighting all leds and showing both monitoring and bypassed status irrespective of the switch status.
I am posting code here.
Plese help
if (Liquid == 1) {
...
}
if (Liquid == 0) {
...
}
else
{
...
}
If Liquid equals 1, the first if evaluates to true so that block will be executed; next the second if evaluates to false so the associated else block will be executed.
No. Which values can Liquid have? In your code, you seem to be trying to cater for 3 states; Liquid can only display 2 states and your description also only mentions 2 states (s far as I understand it.
But you have another input pin that you don't use; maybe you should make use of that as well to influence the flow of your program.
Note:
Seeing digitalRead(), are you using pull-up or pull-down resistors? If they are not on the 'sensors', your inputs can be floating and just give random values.
Hi
Thanks for the reply. I dont have resistors connected to the sensors. its has inbuilt resistors. You are right i am using 2 states only. 1 and 0.
I will try this code and let you know. Thanks alot