Interruptor de límite#
Introducción#
El interruptor de límite es un pequeño sensor digital que detecta el contacto físico con un objeto.

This page uses limit_switch as the example Limit Switch name. Replace it with your own configured name as needed.
A continuación se muestra una lista de los métodos disponibles:
pressing– Returns whether the specified Limit Switch is currently pressed.pressed– Registers a function to be called whenever the Limit Switch is pressed.released– Registers a function to be called whenever the Limit Switch is released.
Constructor – Inicializa manualmente un interruptor de límite.
Limit– Create a Limit Switch.
prensado#
pressing returns a Boolean indicating whether the Limit Switch is currently being pressed.
True– The Limit Switch is being pressed.False– The Limit Switch is not being pressed.
Usage:
limit_switch.pressing()
Parámetros |
Descripción |
|---|---|
Este método no tiene parámetros. |
apretado#
# Display a message after limit_switch is pressed
while not limit_switch.pressing():
pass
brain.screen.print("Limit Switch pressed!")
pressed registers a function to be called whenever the Limit Switch is pressed.
Usage:
limit_switch.pressed(callback, arg)
Parámetros |
Descripción |
|---|---|
|
Una función previamente definida que se ejecuta cuando se presiona el interruptor de límite. |
|
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("Pressed")
# Call my_function whenever limit_switch is pressed
limit_switch.pressed(my_function)
liberado#
released registers a function to be called whenever the Limit Switch is released.
Usage:
limit_switch.released(callback, arg)
Parámetros |
Descripción |
|---|---|
|
Una función definida previamente que se ejecuta cuando se libera el interruptor de límite. |
|
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("Pressed")
# Call my_function whenever limit_switch is released
limit_switch.released(my_function)
Constructor#
Constructors are used to manually create Limit objects, which are necessary for configuring a Limit Switch outside of VEXcode.
Limit#
Limit creates a Limit Switch.
Usage:
Limit(port)
Parámetro |
Descripción |
|---|---|
|
The 3-Wire Port that the Limit Switch is connected to:
|
# Create a Limit Switch in Port A
light_switch = Limit(brain.three_wire_port.a)