В момента ресурсът е наличен само на английски

Calculated read of calibrated value for Light/Color LEGO Mindstorms sensors Pro Preview

Following the Advanced Sensor Calibration course section, it is time to extract the logic for getting a calibrated value into a new block. This block will have an input and on this input, we give the port number. The block will return the calibrated value for this port number. We've built all the other blocks only because of this almost final video here.

  • #646
  • 04 Oct 2017
  • 6:14

Find the min and max from the array

Here is the challenge - give the port number of the sensor, find the index of the minimum and maximum values in the array.

For port 1 the min and max are in cells 0 and 1

For port 2 the min and max are in cells 2 and 3

For port 3 the min and max are in cells 4 and 5

For port 4 the min and max are in cells 6 and 7

How can we come up with a formula here? For the minimum values, we want a calculation that given the following inputs will give us the following outputs:

Input 1, Output 0

Input 2, Output 2 

Input 3, Output 4 

Input 4, Output 6 

The correct formula would be

Output = Input *2 -2

This means

1 -> 0 (1*2 -2)

2 -> 2 (2*2 -2)

3 -> 4 (3*2 -2)

4 -> 6 (4*2 -2)

Beautiful!

Here it is as an EV3-G sequence of blocks

Max formula

For max, given the following inputs, we need the following outputs:

Input 1, Output 1

Input 2, Output 3 

Input 3, Output 5 

Input 4, Output 7

The correct formula would be:

Output = Input *2 -1

This means

1 -> 1 (1*2 -1)

2 -> 3 (2*2 -1)

3 -> 5 (3*2 -1)

4 -> 7 (4*2 -1)

Beautifullllll!