The on light condition changed event allows to run code when the light goes dark or bright. For example, you can use the on light bright event to detect a sudden flash of light.

Live data

The light level returns the current light intensity reading between 0 (no light) and 255 (max light).


In this example, we add a on light bright event to run the sparkle animation when a flash is detected. Using a forever loop, we use the light intensity to control the pitch of the tones played on the speaker.

This guide was first published on Jun 07, 2017. It was last updated on Mar 08, 2024.

This page (Light sensor) was last updated on Jun 07, 2017.

Text editor powered by tinymce.