Printing the value of a Variable within the LEGO EV3 Software Pro Preview

Although we use values to store data and perform some manipulations on it, sometimes we need to display the value stored. Now we will take a look at how we can achieve it.

To access the full video please subscribe to FLLCasts.com

Subscribe

  • #955
  • 24 Sep 2018

Of course, to display the value, we need a display block. So go ahead and take a display block and put it on the canvas:

Next you need to set it to Text mode. It does not matter if you select Text->Pixels or Text->Grid. For the purpose of this tutorial I will select Pixels.

Now in the upper right corner you will find the text that the block will display. If you select it, you can edit it or select Wired. If you choose the latter you will be able to use data wires to pass the text to be displayed. So go and select Wired.

Note how a new parameter has appeared at the beginning of the block.

So now we have only left with creating a new variable and passing it to the display block:

However, if you download and run the program, nothing will happen. That can be really frustrating and confusing for both students and teachers. Actually the program works perfectly, but you need a wait block at the end of it, in order to have time to be able to see the displayed variable on the screen of the brick. So if we add a wait block and set it to 5 seconds, the program will be ready.

Pretty Print

So far, we have seen how we can display a value. However if we display numerous variables, we would like to print some more information about the value that we are displaying. To achieve that we will use another block called Text. The text block can take up to 3 texts and concatenate them into one. So using the text block we can display "Some info to be printed: " before the value. 

 

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