Go Down

Topic: multiple conditions (Read 9296 times) previous topic - next topic

dglstrp

I am curious, I have a controller that needs to look at the status of three inputs to give me a go or no go.

I was planning to nest if statements, then I was looking at the if statements using the && operator.

Can I do something like:

if(door1 == HIGH && door2 == HIGH && door3 ==HIGH)
{
go do this
}

Coding Badly

#1
Nov 30, 2010, 02:22 am Last Edit: Nov 30, 2010, 02:22 am by bcook Reason: 1

Yes.  Or this...

if ( door1 && door2 && door3 )

dglstrp

Now that is interesting, will it be true if all three match in ANY condition or only if HIGH?

AlphaBeta

Any condition:
Code: [Select]
if ( (c1==c2) && (c2==c3) ) {
}

dglstrp

Thanks!
That saves some work.

lloyddean

Quote

Now that is interesting, will it be true if all three match in ANY condition or only if HIGH?


Any non-zero condition.

Go Up