– Testing Statements

We have to give our robot some sources to derive truth values from, we do this with Testing Statements.

The simplest form of testing statement is testing a value of a variable representing a sensor.

Remember when we talked about Truth Values, I said that true had a value of 1 and false had a value of 0.

However, when you test a value of a variable it will always be true if the variable has a non-zero value.

Examples:

g=3 [g is assigned the value of 3]

g is true.

f=5 [f is assigned the value of 5]

f is true.

h=0 [h is assigned the value of 0]

h is false.

You are more likely to use them when incorporating sensors.

So these examples will look more like these:

A=analog10(3); // A is true when the analog sensor 3 detects anything.

black_button as well as the digital sensors are true when being pressed.

Other, common forms of testing statements arecomparisons using logic andinequalities.

NEXT: Branching

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s