sorry for such a simple boring question, but I am pulling my hair out as to why this “If” statement in my function will not resolve the correct answer.
No Matter what address I pass to this function it prints an address correctly, but always actions the first line of my if. No matter what I change the address to that I pass it, it seems to no progress t the else if or the else.
I am sure it is a simple mistake, but I have hashed and rehashed it heaps over the past few days.
The incoming packet is from a loconet network and is a switch command, basically an address, and a status for that address 0 = thrown, 16 = closed
Once I get that sorted I will then work out how to do this without using 16 nested If, if else statements for each IO pin.
Thanks heaps in advance…
Keep in mind there is a heap of missing sketch that sets up the int, and produces the “address”, “output status” and “board addressing”. I didn’t want to clutter the post with excess lines.
// test to see if the swicth address is for this board, if so identify the output state
void Outputtest(int address, int LNstat, int Boardmin)
// this needs to be done better either using switch/case method or array’s.
int Boardmax = (Boardmin + 15);
int LNadd = (address,DEC);
if ((LNadd >= Boardmin) and (LNadd <= Boardmax))
Serial.println(“Address >< test passed”); //visual verification on serial monitor
if ((LNadd = Boardmin +1) and (LNstat == 16))
digitalWrite(outP02 , HIGH);
Serial.println(“Output P02 is high”); // again a bit of visual verification on serial monitor
else if ((LNadd = Boardmin +1) and (LNstat == 0 ))
digitalWrite(outP02 , LOW);
Serial.println(“Output P02 is Low”);
digitalWrite(outP04 , HIGH);
Serial.println(“Output P04 is high, nothing else fitted the if criteria”);
// Print Values to serial screen for fault finding / code checking.
// Serial.println(“failed if test”);
Serial.print(“LNadd in outputest :”);
Serial.print(" Board min : “);
Serial.print(” Boardmax : ");
} // end of outputtest()