Multi LED's using the "if" statement...

Hi everyone wonder if you guys can help here,

I've got 6 led's that are each connected to a microswitch and when there all on or "HIGH" I want to display "all locked" on a TFT screen but only when all are HIGH, I'm trying to do it using the "if" statement this is my text.. I'm sure you'll look at it and laugh but it shows you what I'm trying to achieve, also on a quick note, I'm also trying to stop it looping once I've displayed "All Locked" else it just keeps redrawing the screen... Many thanks..

void AllLock()

{

if (digitalRead(LED1) == HIGH && LED2 == HIGH && LED3 == HIGH && LED4 == HIGH && LED5 == HIGH && LED6 == HIGH)

{

DoorsLocked();

}

}

If your code is within void loop() { } then it will repeat that endlessly whenever it has finished. Perhaps you might want to put some delayMicroseconds below it in loop(). The arduino compiler has that structure built in to it so that you never see anything called "main", similar to compiling

void main()
{
setup()
while(1) {loop();}
}

If your code is within void setup() { } then it will run once after poweron or the restart button is pressed.
That might be handy for testing.

I'm sure you'll look at it and laugh

Yes. You ask for help with one part of your code, but you show something else. I have to laugh at your expectations.

Use a loop and add them up. Then if you get 6, then they are all HIGH.

Cheers guys that replied constructively , I've sorted it using Boolean's,

:slight_smile: