Αναλογικό#

Εισαγωγή#

Μια αναλογική συσκευή διαβάζει συνεχή σήματα τάσης από παλαιότερους αναλογικούς αισθητήρες VEX 3 ακίδων, επιτρέποντας στον εγκέφαλο EXP να μετρά τιμές σε ένα εύρος αντί για υψηλές ή χαμηλές καταστάσεις όπως με το DigitalIn.

Παραδείγματα αισθητήρων είναι:

This page uses analog_a as the example Analog device’s name. Replace it with your own configured name as needed.

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

  • value – Returns the value of the analog device.

  • changed – Registers a function to be called whenever the analog device’s value changes.

Constructor – Μη αυτόματη αρχικοποίηση και ρύθμιση παραμέτρων μιας αναλογικής συσκευής.

αξία#

value returns the value of the analog device representing the voltage signals from different sensors.

Usage:
analog_a.value(units)

Παράμετρος

Περιγραφή

units

Optional. The units to represent the value:

  • PERCENT
  • AnalogUnits.EIGHTBIT – Measure in an 8-bit analog value.
  • AnalogUnits.TENBIT – Measure in a 10-bit analog value.
  • AnalogUnits.TWELVEBIT (default) – Measure in a 12-bit analog value.

άλλαξε#

changed registers a function to be called whenever the analog device’s value changes.

Usage:
analog_a.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("Changed")

# Call my_function whenever analog_a's value changes
analog_a.changed(my_function)

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

Constructors are used to create Analog objects, which are necessary for configuring an Analog device.

AnalogIn#

AnalogIn creates an Analog device.

Usage:
AnalogIn(port)

Παράμετρος

Περιγραφή

port

The 3-Wire Port that the analog device 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 an analog device in Port A
analog_a = AnalogIn(brain.three_wire_port.a)