Potenciómetro#

Introducción#

El potenciómetro es un sensor analógico que mide la posición angular de un eje giratorio. Emite un voltaje proporcional a su posición.

Dependiendo de la versión del potenciómetro, la cantidad de rotación que puede detectar varía:

  • Potenciómetro – Hasta 250 grados

  • Potenciómetro V2 – 330 grados (Continuo)

El potenciómetro VEX V5 V1.

El potenciómetro VEX V5 V2.

Potenciómetro

Potenciómetro V2

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

A continuación se muestra una lista de los métodos disponibles:

  • angle – Reports 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.

Constructores – Inicializa manualmente un potenciómetro o un potenciómetro V2.

ángulo#

angle returns the angular position of the Potentiometer.

Usage:
potentiometer_a.angle(units)

Parámetro

Descripción

unidades

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%)

cambió#

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

Usage:
changed(callback, arg)

Parámetros

Descripción

callback

Una función previamente definida que se ejecuta cuando cambia el valor del potenciómetro.

arg

Opcional. Una tupla que contiene los argumentos que se pasan a la función de devolución de llamada. Consulte Funciones con parámetros para obtener más información.

def my_function():
  brain.screen.print("Value changed!")

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

Constructores#

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)

Parámetro

Descripción

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)

Parámetro

Descripción

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)