Ποτενσιόμετρο#

Εισαγωγή#

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

Ανάλογα με την έκδοση του ποτενσιόμετρου, η ποσότητα περιστροφής που μπορεί να ανιχνεύσει ποικίλλει:

  • Ποτενσιόμετρο – Έως 250 μοίρες

  • Ποτενσιόμετρο V2 – 330 μοίρες (Συνεχές)

Το ποτενσιόμετρο VEX V5 V1.

Το ποτενσιόμετρο VEX V5 V2.

Ποτενσιόμετρο

Ποτενσιόμετρο V2

This page uses potentiometer_a as the example Potentiometer name. Replace it with your own configured name as needed.

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

  • angle – Returns the angular position of the Potentiometer in degrees or as a percent.

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

Κατασκευαστές – Χειροκίνητη αρχικοποίηση ενός Ποτενσιόμετρου ή Ποτενσιόμετρου V2.

γωνία#

angle returns the angular position of the Potentiometer in degrees or as a percent.

Usage:
potentiometer_a.angle(units)

Παράμετρος

Περιγραφή

units

The unit of measurement:

  • DEGREES (default)
    • 0.0 to 250.0 for a Potentiometer
    • 0.0 to 330.0 for a Potentiometer V2
  • PERCENT – The position as a percentage of full rotation (0 to 100%)

άλλαξε#

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

Usage:
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("Value changed!")

# Call my_function whenever potentiometer_a's angle changes
potentiometer_a.changed(my_function)

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

Constructors are used to manually create PotentiometerV2 and Potentiometer objects, which are necessary for configuring Potentiometers outside of VEXcode.

PotentiometerV2#

PotentiometerV2 creates a V5 Potentiometer V2.

Usage:
PotentiometerV2(port)

Παράμετρος

Περιγραφή

port

The 3-Wire Port that the Potentiometer V2 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 Potentiometer V2 in Port A
potentiometer_a = PotentiometerV2(brain.three_wire_port.a)

Potentiometer#

Potentiometer creates a Potentiometer.

Usage:
Potentiometer(port)

Παράμετρος

Περιγραφή

port

The 3-Wire Port that the Potentiometer 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 Potentiometer in Port A
potentiometer_a = Potentiometer(brain.three_wire_port.a)