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 |
---|---|
|
El puerto de 3 cables al que está conectada la entrada digital, ya sea un puerto en el Cerebro o un Expandedor de 3 cables. |
Primero se debe crear un Brain o un 3-Wire Expander antes de poder usarlos para crear un objeto con el constructor de clase digital_in.
// 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 |
---|---|
llamar de vuelta |
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 |
---|---|
llamar de vuelta |
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);
}