entrada digital#
Inicializando la clase digital_in#
Una entrada digital se crea utilizando el siguiente constructor:
The digital_in constructor creates a digital_in object in the specified Three Wire Port:
Parámetro |
Descripción |
|---|---|
|
The 3-Wire Port that the Digital Input is connected to, whether it’s a port on the |
A Brain or 3-Wire Expander must be created first before they can be used to create an object with the digital_in Class constructor.
// Create the Brain.
brain Brain;
// Construct a Digital Input "digin" with the
// digital_in class.
digital_in digin = digital_in(Brain.ThreeWirePort.A);
This digin object will be used in all subsequent examples throughout this API documentation when referring to digital_in class methods.
Métodos de clase#
high()#
The high(callback) method registers a callback function to be called when the Digital Input is high.
Parámetros |
Descripción |
|---|---|
|
Una función que se llamará cuando la entrada sea alta. |
Devuelve: Una instancia de la clase Event.
// Define the inputHigh function with a void return
// type, showing it doesn't return a value.
void inputHigh() {
// The Brain will print that the Digital Input is high
// on the Brain's screen.
Brain.Screen.print("digital input high");
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Run inputHigh when the Digital Input is high.
digin.high(inputHigh);
}
low()#
The low(callback) method registers a callback function to be called when the Digital Input is low.
Parámetros |
Descripción |
|---|---|
|
Una función que se llamará cuando la entrada sea baja. |
Devuelve: Una instancia de la clase Event.
// Define the inputLow function with a void return type,
// showing it doesn't return a value.
void inputLow() {
// The Brain will print that the Digital Input is low
// on the Brain's screen.
Brain.Screen.print("digital input low");
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Run inputLow when the Digital Input is low.
digin.low(inputLow);
}