Ambient Light Sensor
Last updated
Was this helpful?
Last updated
Was this helpful?
You know how to get a handle on the ambient light sensor connected to your computer
You can get the sensor's values and get frequently notified about new values
Working with an sensor works as described in the general article on . In this article, we assume you have successfully initialized the devices with the , and you stored all connected devices on a global variable devices
. We also declared a global variable called ambientLightSensor
.
Next, we need to know the device identifier, which 259:
Once we have a reference to the sensor, we can register a callback function:
Of course, we have to actually define the function:
The sensor delivers only one value, which we can access via the val
object. The value is the light intensity measured in Lux multiplied by 100: