Chapter 11. variables

Variables let you store a value and use it later in the program. For example, say you want to take a sensor reading and then compare that reading to other sensor readings in the future. To do this, you would save the first sensor reading to a variable, which you could access later and compare to other readings. In this chapter, I’ll show you how to use variables and describe the types of problems they solve. I’ll also show you how to use the Constant block, which lets you use a single value to control multiple blocks throughout your program.

the variable block

Think of a variable as a place in the Brick’s memory where you can store a value. The Variable block, found on the Data Operations palette, can either store or retrieve ...

Get The Art of LEGO MINDSTORMS EV3 Programming (Full Color) 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.