Digital In#
Introduction#
The Digital In 3-Wire device allows the V5 Brain to read a digital signal from an external source, such as a switch or sensor. It detects whether the input line is high (receiving 5V) or low (receiving 0V). This can be used to determine on/off states or trigger events in a project.
This page uses dig_in as the example Digital In device name. Replace it with your own configured name as needed.
Below is a list of available methods:
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 – Manually initialize and configure a Digital In device.
DigitalIn– Create a Digital In device.
value#
value returns an integer indicating whether the received signal is a 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()
Parameters |
Description |
|---|---|
This method has no parameters. |
high#
high registers a function to be called whenever the Digital In device sends a high signal (approximately 5V).
Usage:
dig_in.high(callback, arg)
Parameters |
Description |
|---|---|
|
A previously defined function that executes when a high signal is received. |
|
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#
low registers a function to be called whenever the Digital In device sends a low signal (approximately 0V).
Usage:
dig_in.low(callback, arg)
Parameters |
Description |
|---|---|
|
A previously defined function that executes when a low signal is received. |
|
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)
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)
Parameter |
Description |
|---|---|
|
The 3-Wire Port that the Digital In device is connected to:
|
# Create a Digital In device in Port A
dig_in = DigitalIn(brain.three_wire_port.a)