Creating a new variable Pro Preview

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #1284
  • 17 May 2019

The first step for creating a variable is taking a variable block and put it on the canvas. The block is the first one under the red (data) palette.

Variable Name

All variables must have their names as a way to distinguish them. That is why it is extremely important to choose a proper name for the variable. At first, that may seem as a silly task and you will prefer to name your variable with names such as "a" or "var1" or "asdf".

However, once you start working on more complicated tasks, where you will need multiple variables you will get into the situation where you have a project with variables that are hard to distinguish. Probably you will be able to know what a and b store during the time you work on your program, but after a few days it would be impossible, set aside for someone else. It is important the variable names are descriptive enough so that another person could easily understand your program. That program looks a lot better:

To set the name of the variable click on the upper right corner of the block and from the list, select Add Variable 

Then enter the name you have chosen in the popup window and select ok. 

Тhe last step of creating a variable is to set its initial value. The example above shows how to create a variable named "count" with initial value 0.

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

Image for Instructors Remote Training
  • 136
  • 280:11
  • 156
Image for Robotics with LEGO - Level 3.5 - Measuring tools
  • 58
  • 0:00
  • 185
Image for Lesson 5 - Piggy bank. Counting money
  • 7
  • 5
  • 2
  • 3d_rotation 1
Image for Robotics with LEGO - Level 4.0 - Kinesthetic and Memory Game (in development)
  • 59
  • 2:58
  • 200