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 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 ...

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