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

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

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