conclusion

NXT-G variables let you store the data that your program uses. Use the Edit Variables dialog to create variables, and use the Variable block to access the variables within your program. The programs presented in this chapter have shown you a few ways to use variables in your programs. Like data wires, variables add a lot of flexibility to the NXT-G language and are essential for solving many types of problems. You’ll see variables used in many of the programs in the coming chapters.

NXT-G 2.0 allows you to use constants in addition to variables. Constants make it more convenient to use values that don’t change, especially if you use them in many different programs.

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.