Light sensor
The Micro:bit V2 is a sensor-rich board. We know that there are 25 LEDs on the front to display anything using a combination of these LEDs. These 25 LEDs also have built-in light sensors to detect the intensity of light falling on them. The intensity of the light falling on these LEDs is read between 0 to 255. This means the highest intensity value will be read as 255, and the complete darkness will be read as 0. All the intensities in between are equally spaced in between these values.
Figure 14.4 shows the location of the light sensors on a Micro:bit:
Figure 14.4 – Position of light sensors on a Micro:bit (courtesy: https://microbit.org/projects/make-it-code-it/sunlight-sensor/)
Important note
No fixed formula relates the intensity of light with the value. It will completely depend on our observations and adjustments for it to work properly with the light intensity values.
Let us write some simple code that will read the light...