O'Reilly logo

Lego Mindstorms NXT-G Programming Guide, Second Edition by James Floyd Kelly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 16. Inside or Out?

In the last chapter, you learned how to use the COMPARE block to test whether a value was less than, greater than, or equal to another value. The block compares the two numbers and determines whether the statement (A Less than B, A Greater than B, or A Equals B) is True or False.

Sometimes, however, you want to check to see if a value falls inside or outside a range of numbers: Is 28 inside the range 2 through 30? True. Is 50 outside the range 1 through 60? False.

NXT-G provides a block that allows you test the condition of a number (A) to determine whether it falls inside or outside the range of two other numbers (B and C). Here's how it works.

The RANGE Block

Just like the COMPARE block, the RANGE block uses the following ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required