A variable is a container for storing a value that can be defined, referenced, and updated as a program runs. The Blockly app allow you to create and use variables in your program of the Dash robot.
To create a variable, go to the “Variables” menu and select the “Set” Block. Drag it onto the stage, then tap on the orange. In Blockly, variables are represented by one of 5 fruits--orange, banana, apple, cherries, or watermelon. This is somewhat limiting because you can’t name your variable whatever you want, as in traditional programming.
You are also somewhat limited in the types of data you can store in your variable container. Most programming languages allow you to store three types of variables: any number, any string of letters and numbers, or a true/false value.
In Blockly, however, you can only store a number, and it must be a number under 10,000.
You can, however, set a variable equal to some interesting variations of a number, including another variable, a random number between two extremes, or even a numerical value gathered by Dash’s sensor data.
Other blocks in the variables menu allow you to change the value stored inside a variable using the standard arithmetic operators; write loops or conditions using variables; or execute a limited number of commands with a variable as the parameter.
Ещё видео!