03.02. FlightSimOnCommandSwitch
Jorg Neves Bliesener edited this page Jan 13, 2019
·
2 revisions
This switch is very similar to the FlightSimOnOffCommandSwitch object, but only sends a command when it is being closed. No command is sent when the switch is opened.
As there's only a single command, it can be assigned directly to the switch
object. As with FlightSimOnOffCommandSwitch,
the pin number can be specified on declaration or during
setup()
:
#include <FlightSimSwitches.h>
// always declare FlightSimSwitches first
FlightSimSwitches switches;
// Pin number specified in object declaration
FlightSimOnCommandSwitch switch1(2); // Switch connected between pin 2 and GND
// Pin Number specified in setup()
FlightSimOnCommandSwitch switch2;
void setup() {
delay(1000);
// ...
// set switch1 on command
switch1 = XPlaneRef("on/command/1");
// set switch2 pin and Commands
switch2.setPosition(3);
switch2 = XPlaneRef("on/command/2");
switches.setDebug(DEBUG_SWITCHES);
switches.begin();
}
void loop() {
FlightSim.update();
switches.loop();
}