Ψηφιακή είσοδος#

Εισαγωγή#

Η συσκευή Ψηφιακής Είσοδος 3-Wire επιτρέπει στο V5 Brain να διαβάζει ένα ψηφιακό σήμα από μια εξωτερική πηγή, όπως έναν διακόπτη ή έναν αισθητήρα. Ανιχνεύει εάν η γραμμή εισόδου είναι υψηλή (λήψη 5V) ή χαμηλή (λήψη 0V). Αυτό μπορεί να χρησιμοποιηθεί για τον προσδιορισμό καταστάσεων ενεργοποίησης/απενεργοποίησης ή την ενεργοποίηση συμβάντων σε ένα έργο.

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

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

  • 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 – Μη αυτόματη αρχικοποίηση και διαμόρφωση μιας συσκευής ψηφιακής εισόδου.

αξία#

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

  • 1 – The Digital In port is receiving a high signal (approximately 5V).

  • 0 – The Digital In port is receiving a low signal (approximately 0V).

Usage:
dig_in.value()

Παράμετροι

Περιγραφή

Αυτή η μέθοδος δεν έχει παραμέτρους.

ψηλά#

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

Usage:
dig_in.high(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("High")

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

χαμηλός#

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

Usage:
dig_in.low(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("Low")

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

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

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)

Παράμετρος

Περιγραφή

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)