Light#
Introduction#
The Light Sensor measures the brightness of light reflected from or shining on an object. It outputs an analog value that represents how much light is detected.

This page uses light_sensor as the example Light Sensor name. Replace it with your own configured name as needed.
Below is a list of available methods:
brightness– Returns the amount of light detected by the Light Sensor as a percent.changed– Registers a function to be called whenever the Light Sensor’s brightness value changes.
Constructor – Manually initialize a Light Sensor.
Light– Create a Light Sensor.
brightness#
brightness returns the amount of light detected by the Light Sensor as a percent.
Usage:
light_sensor.brightness(units)
Parameter |
Description |
|---|---|
units |
Optional. The unit to return the brightness with:
|
changed#
changed registers a function to be called whenever the Light Sensor’s brightness value changes.
Usage:
light_sensor.changed(callback, arg)
Parameters |
Description |
|---|---|
|
A previously defined function that executes when the Light Sensor’s brightness value changes. |
|
Optional. A tuple containing arguments to pass to the callback function. See Functions with Parameters for more information. |
def my_function():
brain.screen.print("Brightness changed")
# Call my_function whenever the brightness changes
light_sensor.changed(my_function)
Constructor#
Constructors are used to manually create Light objects, which are necessary for configuring a Light Sensor outside of VEXcode.
Light#
Light creates a Light Sensor.
Usage:
Light(port)
Parameter |
Description |
|---|---|
|
The 3-Wire Port that the Light Sensor is connected to:
|
# Create a Light Sensor in Port A
light_sensor = Light(brain.three_wire_port.a)