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.

El sensor de luz VEX V5.

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:

  • PERCENT (default)

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

callback

Una función previamente definida que se ejecuta cuando cambia el valor de brillo del sensor de luz.

arg

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

port

The 3-Wire Port that the Light Sensor is connected to:

  • On the V5 Brainbrain.three_wire_port.x where x is the number of the port.
  • On a 3-Wire Expanderexpander.a where expander is the name of the expander instance.

# Create a Light Sensor in Port A
light_sensor = Light(brain.three_wire_port.a)