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.
- 04 Oct 2017
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)