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 26. My Block Is Your Block

Don't go crazy looking for an actual NXT-G block on the palettes called "My Block." It doesn't exist. My Block is something that you are going to create. A My Block is a collection of NXT-G blocks that you have grouped together and may wish to reuse. My Block represents a feature that lets you build and reuse components. So let's jump right in and see how this approach of reusing components can help you.

Creating a My Block

Take a look at the following pseudo-code and the matching NXT-G program in Figure 26-1. (Adding comments to the blocks to make them a little easier to figure out which is which—it's a lot of MOVE blocks to keep track of.) If SPOT performs these movements, he should follow a square-shaped path ...

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