Chapter 20. Basic Math

Don't you just love short chapters? Well, I promise this is going to be another extremely short chapter. So get ready to add another programming block to your collection of tools—you're going to turn your robot into a calculator.

The MATH Block

Your robots can do some very simple math: addition, subtraction, multiplication, and division. Take a look at Figure 20-1, which shows the MATH block and its configuration panel.

The MATH block and its configuration panel

Figure 20-1. The MATH block and its configuration panel

The MATH block uses two values: A and B. For NXT-G 1.0 users, these values can be positive or negative integers. An integer is a whole number with no decimal ...

Get Lego Mindstorms NXT-G Programming Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.