The micro:bit does not have a special light sensor device fitted. However, it can use the LEDs of the matrix display to estimate the amount of ambient light.

Javascript Blocks Editor

The light level block can be found under Input

As an example, the light level could be asigned to a variable

Python Editor

Light sensing is not yet available in MicroPython.

Further Information

The technique has been around for a while. It uses an LED both as an output device, and an input device. When the output pin of the microprocessor drives a voltage across the LED, the LED lights up. If the micro-controller then sets that drive pin as an input, and times how long it takes for the voltage at the top end of the LED to collapse, that time is roughly proportional to the amount of ambient light.

There is some background into the general technique in these links, which include details on not just how to sense ambient light with LEDs, but how to transfer small amounts of data wirelessly using the same technique.

Keywords for search: light sensing, light sensor, measure light level