Skip to Main Content
The Art of LEGO MINDSTORMS NXT-G Programming
book

The Art of LEGO MINDSTORMS NXT-G Programming

by Terry Griffin
August 2010
Intermediate to advanced content levelIntermediate to advanced
288 pages
13h 21m
English
No Starch Press
Content preview from The Art of LEGO MINDSTORMS NXT-G Programming

the range block

The final math-related block is the Range block, which determines whether a number is inside or outside a range of numbers. For example, say you want to know whether the reading from the Light Sensor is between 40 and 60. You could pass the output value from a Light Sensor block to two Compare blocks and a Logic block, as shown in Figure 14-31.

Is the Light Sensor reading between 40 and 60?

Figure 14-31. Is the Light Sensor reading between 40 and 60?

This approach will certainly work. However, checking to see whether a number is in a certain range is so useful that NXT-G provides a quicker way to do this. Using the Range block, you can perform the same comparison using one block ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Art of LEGO MINDSTORMS EV3 Programming (Full Color)

The Art of LEGO MINDSTORMS EV3 Programming (Full Color)

Terry Griffin

Publisher Resources

ISBN: 9781593272180Errata