Following the Advance Light/Color sensors calibration for a minimum value for a single sensor tutorial, in this one, we continue with finding the maximum value detected by a sensor and storing this value in an array.
- #642
- 04 Oct 2017
- 4:10
- LEGO MINDSTORMS, LEGO MINDSTORMS EV3
- FIRST LEGO League, EV3-G, Sensors, EV3, Light and Color Sensor, FLL, Programming
Sensor Raw Value
We take the sensor raw value and use it both for minimum and for maximum.
Compare of previous Max
Initially, the Maximum value is set to -12345. This is a very small value and we are sure that even the first detection of a value from the sensor will be more than the initial maximum value. After that, the comparison is the following
if currentValue > knownMaximum then currentValue is set to the value of knownMaximum
The same logic is implemented in the program with the only difference that the knownMaximum is stored in an array.
We read from the maximum value and compare with the cell with index 3 from the array. Then we do a SWITCH and IF the value read from the array is less than the value from the Sensor we write this value in the array.
English
In the previous tutorial from the course we stopped at calibrating the minimum value for sensor 2 and in this tutorial we'll calibrate the maximum value again for a single sensor - for sensor 2.
First, the robot moves back. We must set the power to -20 but we have our sensors right here and I'll place the sensors before the line something like this. And then I'll start the program again. The robot moves for about a second, calibrates but nothing is displayed on the brick screen. And in our next program we'll display the newly calibrated values on the brick screen.
What I'll do is again I'm in the loop and this loop I would like to read the maximum value that we currently have for sensor 2. And this maximum value is stored in the numeric array and this numeric array is MinMaxArray and we read and then we have an operation - array operation. Let me just move this to the center of the screen. And zoom this in. So, I would like to read cell with index 3. So, I have 0 and 1 for the first sensor and 2 and 3 for the second sensor. And after I read this value I must compare it. And I compare to the currently detected value by the raw sensor. Zoom out. Take the value from here. Attach it right here. Zoom in. And we must compare. So, if the current detected by the sensor maximum value this is the one stored in the array. So, if the one stored in the array is less than the currently detected , then and only then we must write the currently detected to the array. I will do this. We have a switch and for this switch again set it as logic, flat
and right here, move it to the center of the screen we take the array.
We read value from the array and read numeric array, an operation to write at a certain index. So, we take the array, we want to write in the cell with index 3 and the value that we want to write is the value that we have from the sensor. So, zoom out again, take the value from the sensor, move it right here. Zoom in and at the end write the final result again into the array. Write numeric array.
And in this way at the end we'll have the minimum and maximum value for sensor 2 set to the minimum and maximum value detected by the sensor itself. And this will continue for about a second. So, let's start the program and let's see what happens.
Курсове и занятия включващи този Урок
Този Урок е използван в следните курсове и занятия.

FIRST LEGO League Competition. Constructing and Programming a Robot Base
This course if used by teams, mentors and students to structure the preparation for the Robotics Game of the FIRST LEGO League Robotics Competitions. One thing that is common each year at FLL is that experience matters a lot. Our goal with this course is to quickly bring new teams up to speed with experienced teams and to share some new tricks, patterns, constructions with the more experienced teams.
- 42
- 249:53
- 10
Advanced Light/Color Sensor Calibration
Would you like to resolve all the problems with the light/color sensors that you have? And to make all of them work in a predictable, stable way even when using more than one MINDSTORMS colour sensors.
When using Color sensors it is important to calibrate them depending on the light conditions in your venue. In this way, the calibrated sensor will show values between 0 and 100 independent of the light conditions. But using the default EV3 colour calibration available in the colour sensor block could lead to unpredicted problems that are difficult to track and resolved especially when used with multiple Color sensors. So in this series of tutorial we implement the calibration ourselves discussing the principles of colour sensor calibration.
- 15
- 0
- 4
- 3d_rotation 0