View unanswered posts | View active topics It is currently Wed Jul 30, 2014 10:05 pm






Reply to topic  [ 4 posts ] 
Need Help Writing And, Or Statements 
Author Message
Rookie

Joined: Wed Jan 21, 2009 1:40 pm
Posts: 14
Location: Brookings OR
Post Need Help Writing And, Or Statements
We would like to use an and statement in our program so it looks at both of our sensors at once, how would you do this? Any help would be appreciated. :poke:


Thu Feb 12, 2009 2:45 pm
Profile
Novice

Joined: Tue Jan 13, 2009 5:22 pm
Posts: 72
Location: USA, Pennsylvania
Post Re: Need Help Writing And, Or Statements
You can always use a void statement.
Quote:
void test()
{
PlayTone(1500, 1000);
wait1Msec(1);
}
void test two()
{
motor[motorA] = 100;
}
task main()
{
while(true)
{
test();
test two();
}
}

_________________
We need a Linux Version!


Thu Feb 12, 2009 5:01 pm
Profile WWW
Professor

Joined: Fri Sep 19, 2008 1:22 am
Posts: 200
Post Re: Need Help Writing And, Or Statements
The AND and OR operators in RobotC are represented by the symbols "&&" for AND and "||" for OR.

Code:
if (joy1Btn(1) && joy1Btn(2))
{
    // Code to run if both buttons are pressed
}

if (joy1Btn(1) || joy1Btn(2))
{
    // Code to run if either button is pressed
}

_________________
Jeff McBride
Benson Robotics Club


Thu Feb 12, 2009 8:51 pm
Profile
Rookie

Joined: Wed Jan 21, 2009 1:40 pm
Posts: 14
Location: Brookings OR
Post Re: Need Help Writing And, Or Statements
That's exactly what i was looking for, thank you :D


Fri Feb 13, 2009 2:42 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.