Skip to content

03.03. FlightSimOffCommandSwitch

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 the switch is being opened. No command is sent when the switch is closed.

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
FlightSimOffCommandSwitch switch1(2); // Switch connected between pin 2 and GND

// Pin Number specified in setup()
FlightSimOffCommandSwitch switch2;

void setup() {
  delay(1000);
  // ...
  // set switch1 on command
  switch1 = XPlaneRef("off/command/1");

  // set switch2 pin and Commands
  switch2.setPosition(3);
  switch2 = XPlaneRef("off/command/2");

  switches.setDebug(DEBUG_SWITCHES);
  switches.begin();
}

void loop() {
  FlightSim.update();
  switches.loop();
}