How does the light sensing feature work?

Does the micro:bit have a light sensor?

Which languages support the light sensing feature?

How can I measure light level with the micro:bit?


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

The technique used in the micro:bit is described in this document:



In blocks: 


In touch develop:


NOTE: Light sensing is not yet available in MicroPython or Code Kingdoms.


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.


06 NOV 2016