Luz#
Introducción#
El Sensor de Luz mide la intensidad de la luz reflejada o incidida sobre un objeto. Emite un valor analógico que representa la cantidad de luz detectada.

This page uses light_sensor as the example Light Sensor name. Replace it with your own configured name as needed.
A continuación se muestra una lista de los métodos disponibles:
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 – Inicializa manualmente un sensor de luz.
Light– Create a Light Sensor.
brillo#
brightness returns the amount of light detected by the Light Sensor as a percent.
Usage:
light_sensor.brightness(units)
Parámetro |
Descripción |
|---|---|
unidades |
Optional. The unit to return the brightness with:
|
cambió#
changed registers a function to be called whenever the Light Sensor’s brightness value changes.
Usage:
light_sensor.changed(callback, arg)
Parámetros |
Descripción |
|---|---|
|
Una función previamente definida que se ejecuta cuando cambia el valor de brillo del sensor de luz. |
|
Opcional. Una tupla que contiene los argumentos que se pasan a la función de devolución de llamada. Consulte Funciones con parámetros para obtener más información. |
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)
Parámetro |
Descripción |
|---|---|
|
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)