View unanswered posts | View active topics It is currently Fri Apr 18, 2014 7:23 pm






Reply to topic  [ 3 posts ] 
Control Functions 
Author Message
Rookie

Joined: Fri Feb 03, 2012 4:30 pm
Posts: 2
Post Control Functions
Is is possible to write a code similar to the following?
I have a student who wants to use the linefollower with a range of values.

IF (sensorvalue) 350< x < 700


Thu Mar 08, 2012 1:52 pm
Profile
Novice
User avatar

Joined: Sat Jul 10, 2010 3:06 pm
Posts: 86
Location: Roanoke, VA
Post Re: Control Functions
jgillespie wrote:
Is is possible to write a code similar to the following?
I have a student who wants to use the linefollower with a range of values.

IF (sensorvalue) 350< x < 700

Yes and no. You cannot have a "compound" inequality as condition for an if statement.

HOWEVER... :)

350 < x < 700 is the same thing as saying

350 < x
AND
x < 700

which is the same as
x > 350
AND
x < 700

Converted to code:
Code:
if ((SensorValue[sensor] > 350) && (SensorValue[sensor] < 700))


&& is the logical AND

//Andrew

_________________
Check out my website! www.RoboDesigners.com

VRC Team 2190

Twitter: @RoboDesigners


Thu Mar 08, 2012 2:21 pm
Profile WWW
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 403
Post Re: Control Functions
We also have a video produced which might help illustrate how this works: http://www.education.rec.ri.cmu.edu/products/teaching_robotc_cortex/reference/video/booleanlogic_p2.html

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Mon Mar 12, 2012 2:49 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.