A common question is how to display arrays on the LEGO Mindstorms EV3 brick screen. Displaying values from an array is not different from any other display operation. In this tutorial, we would look at displaying two specific values. The minimum and the maximum for a specific sensor from the Advance Calibration Course Section
- 04 Oct 2017
- LEGO MINDSTORMS
- Array, EV3, Display, Light and Color Sensor, Sensors, FLL, Programming
- K.Mitov, D.Staykov
Displaying array value with a hardcoded index
Three blocks. Access array. Read Operation. Array.
The first block is an array access block. The second is an array operation that read a cell from the array. And the third is a display block.
The same applies also for the Max values.
We previously stopped at the program with the calibration and when we start a program it calibrates but it does not display anything on the screen and in this tutorial we would like to display the values from the array to the screen. This here is the program and in this program at the end as we stop we would like to display the minimum and maximum values on the brick screen and for this we'll use the brick screen. And we can display text. Now, the question is: How do we display text on the brick screen from the array? First, I'll take a new variable to read a numeric array and I would like to read from the array the cell with index 2. And this is the minimum value. And I would like to display this value on the screen.
Set the display to wired, we'll clean it and then display the cell with index 2 on the brick screen. Then we want to display the maximum value again read numeric array and an operation for reading from the numeric array and we want to display the value in the cell with index 3. And this is the maximum value for sensor 2. Again a display block like this. Text, wired, without cleaning
so that the values are not one over the other we want to display it on let's say Y=20. And at the end we need a small wait for touching the brick buttons and if we pump the brick button, we'll stop the program. In this way we'll display the minimum and maximum values that the sensor has detected and these are the values that we'll use for our calibration. And in this way you can display values from different arrays. So, the array is MinMax, the operation is read and this is the display block.
Moving with the robot, calibrating and displaying on the brick screen the two values for minimum and maximum for the second sensor - the sensor connected on port 2. So, the minimum is 5 and the maximum is 77. And from here we can use these values to actually detect lines, follow, etc. But first we'll need to also calibrate the other sensors. And we have 3 color sensors. And this is something that we'll do in the next few tutorials.
Courses and lessons with this Tutorial
This Tutorial is used in the following courses and lessons