grouping common settings

It’s not unusual for a program to use several blocks with the same settings. For example, the WallFollower program contains seven Move blocks that all use the same Power setting. If you decide to change the setting from 35 to 45, you need to make sure you change that setting on all seven blocks. That can become problematic when you’re trying several different Power settings, in search of the perfect balance between speed and accuracy; it’s almost inevitable that you’ll forget to change the setting on one of the blocks.

To avoid this problem, use variables to group common settings. For example, Figure 11-15 shows a modified version of the AroundTheBlock program from Chapter 4. Here you use a variable (named Power) to control ...

Get The Art of LEGO MINDSTORMS NXT-G Programming 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.