Αισθητήρας φωτός#

Εισαγωγή#

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.

Ο αισθητήρας φωτός VEX EXP.

Κατασκευαστής κλάσης#

light(
  triport::port &port );

Καταστροφέας κλάσης#

Destroys the light object and releases associated resources.

virtual ~light();

Παράμετροι#

Παράμετρος

Τύπος

Περιγραφή

port

triport::port &

The 3-Wire Port that the Light Sensor is connected to, written as Brain.ThreeWirePort.X or ExpanderName.X, where X is the port letter (for example, Brain.ThreeWirePort.A or Expander1.A).

Παραδείγματα#

// Create a light instance in Port A
light LightA = light(Brain.ThreeWirePort.A);

Συναρτήσεις Μελών#

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#

Επιστρέφει την ποσότητα φωτός που ανιχνεύεται από τον αισθητήρα φωτός. Αυτό μπορεί να χρησιμοποιηθεί για να ελέγξει εάν ένα αντικείμενο είναι αρκετά φωτεινό ώστε να αναφέρει με ακρίβεια άλλα οπτικά δεδομένα.

Available Functions
int32_t brightness(
  percentUnits units = percentUnits::pct );

Parameters

Παράμετρος

Τύπος

Περιγραφή

units

percentUnits

The unit that represents the brightness: percent / pct (default) — percent

Return Values

Returns an int32_t representing the brightness measured by the Light Sensor as a percent in the range 0 - 100%.

Examples
// 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);