Sensor de luz#
Introducción#
The light class is used with the Light Sensor, which measures the brightness of light reflected from or shining on an object. It outputs an analog value that represents how much light is detected.

Constructor de clases#
light(
triport::port &port );
Instructor de clase#
Destroys the light object and releases associated resources.
virtual ~light();
Parámetros#
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The 3-Wire Port that the Light Sensor is connected to, written as |
Ejemplos#
// Create a light instance in Port A
light LightA = light(Brain.ThreeWirePort.A);
Funciones de los miembros#
The light class includes the following member functions:
brightness— Returns the amount of light detected by the Light Sensor.
Before calling any light member functions, a light instance must be created, as shown below:
/* This constructor is required when using VS Code.
Light Sensor configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */
// Create a light instance in Port A
light LightA = light(Brain.ThreeWirePort.A);
brightness#
Devuelve la cantidad de luz detectada por el sensor de luz. Esto puede utilizarse para comprobar si un objeto es lo suficientemente brillante como para informar con precisión otros datos visuales.
Available Functionsint32_t brightness(
percentUnits units = percentUnits::pct );
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The unit that represents the brightness: |
Returns an int32_t representing the brightness measured by the Light Sensor as a percent in the range 0 - 100%.
// Get Light Sensor brightness in range of 0% - 100%.
int32_t value = LightA.brightness();
// Print the brightness of the Light Sensor to the
// Brain's screen.
Brain.Screen.print(value);