 |
 |
|
|
|
|
|
| What is the Variable block for? |
The Variable block (located in the 'Data' section in the 'complete palette' tab on the left side of the screen) is used to store information for later use. This data can be anything ranging from a light sensor value to a boolean logic (true/false) result.
1. The first step to using the Variable block is to create a variable. Start by clicking on the Edit menu, then 'Define Variables'. Here, you can create a new variable with an input name and a data type (number, logic, text).

2. Place the variable block into your program. Then, using the configuration panel, select the variable you created. You can choose either to read the variable (which lets you view the current value of the variable) or to write it (store a new value into the variable). If you wish to put in a default value to write to the variable, you can input something into the Value field.

The attached program, variable.rbt, makes the robot store the light sensor value of one position, travel for 5 seconds, and then show the stored value of the light sensor on the NXT screen.
|