# How does the calibrateLight block work

**URL:** https://forum.makecode.com/t/how-does-the-calibratelight-block-work/596
**Category:** EV3
**Created:** [October 9, 2019, 9:56am UTC](https://forum.makecode.com/t/how-does-the-calibratelight-block-work/596 "2019-10-09T09:56:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![mkrdroid](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@mkrdroid](https://forum.makecode.com/u/mkrdroid)
#### Post date: [October 9, 2019, 9:56am UTC](https://forum.makecode.com/t/how-does-the-calibratelight-block-work/596/1 "2019-10-09T09:56:46Z")

</div>

I’m unclear how to the calibrateLight block works. How does it know the sensor is over the dark or light area? Does it sample several times a second and find the min and max reflection in a given time or until the program ends. Are the calibration values stored or do I run the procedure every time? Also, if there are two sensors do we calibrate them individually.

---

<div class="post-metadata">

### Author: ![peli](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/peli/32/12_2.png) [@peli](https://forum.makecode.com/u/peli)
#### Post date: [October 9, 2019, 3:11pm UTC](https://forum.makecode.com/t/how-does-the-calibratelight-block-work/596/2 "2019-10-09T15:11:12Z")

</div>

For reference, here is the impl: [https://github.com/microsoft/pxt-ev3/blob/master/libs/color-sensor/color.ts#L333](https://github.com/microsoft/pxt-ev3/blob/master/libs/color-sensor/color.ts#L333)

It resets the sensor, then collects readings until it does not change anymore, compute min/max range and applies a threshold. It does not store the results yet but it’s an excellent suggestion.

2 sensors is not supported. You would have to write your own sequence. I guess when we store the data things would be easier as well.
