Hello guys, I am using Arduino Mega 2560, I want to add multiple statements for a condition in 'IF-ELSE' function.
But only the first statement follows the if-else condition. Where am i going wrong?
Below is a part of the code.
Only the fillRect works according to the condition.
digitalWrite runs as the code is scanned.
void Valves()
{
if (EQ == 0) {
tft.fillRect(0, 260, 40, 40, TFT_RED);
digitalWrite(31, HIGH);
}
else tft.fillRect(0, 260, 40, 40, TFT_GREEN);
digitalWrite(31, LOW);
if (RF == 0) {
tft.fillRect(50, 260, 40, 40, TFT_RED);
digitalWrite(33, LOW);
}
else tft.fillRect(50, 260, 40, 40, TFT_GREEN);
digitalWrite(33, HIGH);
if (LW == 0) {
tft.fillRect(100, 260, 40, 40, TFT_RED);
digitalWrite(35, LOW);
}
else tft.fillRect(100, 260, 40, 40, TFT_GREEN);
digitalWrite(35, HIGH);
if (LF == 0) {
tft.fillRect(150, 260, 40, 40, TFT_RED);
digitalWrite(37, LOW);
}
else tft.fillRect(150, 260, 40, 40, TFT_GREEN);
digitalWrite(37, HIGH);
if (RW == 0) {
tft.fillRect(200, 260, 40, 40, TFT_RED);
digitalWrite(39, LOW);
}
else tft.fillRect(200, 260, 40, 40, TFT_GREEN);
digitalWrite(39, HIGH);
}