Pages: [1]   Go Down
Author Topic: multiple conditions  (Read 6066 times)
0 Members and 2 Guests are viewing this topic.
Utah
Offline Offline
Newbie
*
Karma: 0
Posts: 24
High Priced Toy Specialist
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
}
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 176
Posts: 12285
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Yes.  Or this...

if ( door1 && door2 && door3 )
« Last Edit: November 29, 2010, 08:22:55 pm by bcook » Logged

Utah
Offline Offline
Newbie
*
Karma: 0
Posts: 24
High Priced Toy Specialist
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Norway@Oslo
Offline Offline
Edison Member
*
Karma: 12
Posts: 2033
loveArduino(true);
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Any condition:
Code:
if ( (c1==c2) && (c2==c3) ) {
}
Logged

Utah
Offline Offline
Newbie
*
Karma: 0
Posts: 24
High Priced Toy Specialist
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks!
That saves some work.
Logged

Des Moines, WA - USA
Offline Offline
God Member
*****
Karma: 25
Posts: 779
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Any non-zero condition.
Logged

Pages: [1]   Go Up
Jump to: