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

Following the Advance Sensor Calibration course section, we found the min and max values detected by each sensor. Now it is time for the real deal of the calibration. Detect the current value from the sensor and find what is the percentage of this value for the range between min and max. 

  • #636
  • 04 Oct 2017
  • 8:34

Percentage

What is a percentage? Go figure it out. Here is a very good video Finding a percentage | Decimals | Pre-Algebra | Khan Academy. After you understand the concept of percentage we are waiting for you back here.

Percentage of sensor value min and max 

The percentage is calculated using the following formula:

(currentValue - min)/(max-min)*100

We are taking the value from the sensor, along with the value for min and max from the array and we do a calculation of the percentage. This formula will give us a value between 0 and 100 when 0 is DARK and 100 is BRIGHT. (I don't want to say black and white here)

 

Courses and lessons with this Tutorial

This Tutorial is used in the following courses and lessons

Image for FIRST LEGO League Competition. Constructing and Programming a Robot Base
  • 42
  • 249:53
  • 10
Image for Advanced Light/Color Sensor Calibration
  • 15
  • 0
  • 4
  • 3d_rotation 0