I think this still doesn't solve my initial question. Your code flips the "Action needed" Switch if ANY of the Array members fulfills the if statement.
I'm looking for a simpler way to write if ALL of them do.
Also, could you please point out the errors in my code. It compiles fine for me, but I'm always appreciating an opportunity to learn. Thanks again!
Oh I guess setting the pins to OUTPUTS is kind of meaningless in this code... It's a leftover from the more complicated one, where the Array contains Arduino Pins. I want to set them all to OUTPUTs
I think the for loop does accomplish this, no? At i=0 the first member of the Array is set to OUTPUT, at i=1, the 2nd member is set to OUTPUT and so on...
seemoo:
I think this still doesn't solve my initial question. Your code flips the "Action needed" Switch if ANY of the Array members fulfills the if statement.
I'm looking for a simpler way to write if ALL of them do.
Just turn the logic on its head - like this
boolean actionNeeded = true;
for (byte i = 0; i < ArraySize; i++)
{
if (TestArray[i] > 50)
{
actionNeeded = false;
}
}
boolean actionNeeded = true;
for (byte i = 0; i < ArraySize; i++)
{
if (TestArray[i] > 50)
{
actionNeeded = false;
}
}
This turns actionNeeded to false if ANY of the elements is bigger than 50. It could be one of them or all of them. Correct?
I'm looking for a statement that turns actionNeeded to false when ALL of the Array members fulfill the if condition.
Thanks again