entrada analógica#
Inicializando la clase analog_in#
Una entrada analógica se crea utilizando el siguiente constructor:
The analog_in constructor creates an analog_in object in the specified Three Wire Port.
Parámetro |
Descripción |
|---|---|
|
The 3-Wire Port that the Analog 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 analog_in Class constructor.
// Create the Brain.
brain Brain;
// Construct an analog_in "analogIn" with the
// analog_in class.
analog_in analogIn = analog_in(Brain.ThreeWirePort.A);
This analogIn object will be used in all subsequent examples throughout this API documentation when referring to analog_in class methods.
Métodos de clase#
changed()#
The changed(callback) method registers a function to be called when the value of the analog input changes.
Parámetros |
Descripción |
|---|---|
|
Una función que se llamará cuando cambie el valor de la entrada analógica. |
Devuelve: Una instancia de la clase Event.
// Define the AnalogInputChanged function with a void return
// type, showing it doesn't return a value.
void AnalogInputChanged() {
// The Brain will print that the Analog Input changed on
// the Brain's screen.
Brain.Screen.print("analog input changed");
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Run analogInputChanged when the value of the
// Analog Input changes.
analogIn.changed(analogInputChanged);
}