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

Εισαγωγή#

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

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

This page uses light_sensor as the example Light Sensor name. Replace it with your own configured name as needed.

Παρακάτω είναι μια λίστα με τις διαθέσιμες μεθόδους:

  • brightness – Returns the amount of light detected by the Light Sensor.

  • changed – Registers a function to be called whenever the Light Sensor’s brightness value changes.

Constructor – Χειροκίνητη αρχικοποίηση ενός αισθητήρα φωτός.

  • Light – Create a Light Sensor.

λάμψη#

brightness returns the amount of light detected by the Light Sensor as an integer.

Usage:
light_sensor.brightness(units)

Παράμετρος

Περιγραφή

units

Optional. The unit to return the brightness with: PERCENT (default).

άλλαξε#

changed registers a function to be called whenever the Light Sensor’s brightness value changes.

Usage:
light_sensor.changed(callback, arg)

Παράμετροι

Περιγραφή

callback

Μια προηγουμένως καθορισμένη συνάρτηση που εκτελείται όταν αλλάζει η τιμή φωτεινότητας του αισθητήρα φωτός.

arg

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)

Κατασκευαστής#

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)

Παράμετρος

Περιγραφή

port

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

  • On the EXP 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)