Entrada digital#

Introducción#

El dispositivo Entrada Digital de 3 Cables permite al V5 Brain leer una señal digital de una fuente externa, como un interruptor o un sensor. Detecta si la línea de entrada es alta (recibe 5 V) o baja (recibe 0 V). Esto puede usarse para determinar estados de encendido/apagado o activar eventos en un proyecto.

This page uses dig_in as the example Digital In device name. Replace it with your own configured name as needed.

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

  • value – Returns an integer indicating whether the received signal is high or low.

  • high – Registers a function to be called whenever the Digital In device sends a high signal (approximately 5V).

  • low – Registers a function to be called whenever the Digital In device sends a low signal (approximately 0V).

Constructor: inicializa y configura manualmente un dispositivo de entrada digital.

valor#

value returns an integer indicating whether the received signal is a high or low.

  • 1 – El puerto de entrada digital está recibiendo una señal alta (aproximadamente 5 V).

  • 0 – El puerto de entrada digital está recibiendo una señal baja (aproximadamente 0 V).

Usage:
dig_in.value()

Parámetros

Descripción

Este método no tiene parámetros.

alto#

high registers a function to be called whenever the Digital In device sends a high signal (approximately 5V).

Usage:
dig_in.high(callback, arg)

Parámetros

Descripción

callback

Una función previamente definida que se ejecuta cuando se recibe una señal alta.

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("High")

# Call my_function whenever dig_in is high
dig_in.high(my_function)

bajo#

low registers a function to be called whenever the Digital In device sends a low signal (approximately 0V).

Usage:
dig_in.low(callback, arg)

Parámetros

Descripción

callback

Una función previamente definida que se ejecuta cuando se recibe una señal baja.

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("Low")

# Call my_function whenever dig_in is low
dig_in.low(my_function)

Constructor#

Constructors are used to manually create DigitalIn objects, which are necessary for configuring a Digital In device outside of VEXcode.

DigitalIn#

DigitalIn creates a Digital In device.

Usage:
DigitalIn(port)

Parámetro

Descripción

port

The 3-Wire Port that the Digital In device 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 Digital In device in Port A
dig_in = DigitalIn(brain.three_wire_port.a)