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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.