Jump to content

Recommended Posts

Posted (edited)

Someone asked about this on the FlightPanels Discord, so I thought I'd post here.
This is how easy it is to run a combination of DCS-BIOS and a HID on the same Arduino.
It uses a Leonardo or Pro Micro (needs the 32u4 processor).
This example is for the TF-51D, so anyone can try it. 

/*
  Tell DCS-BIOS to use a serial connection and use interrupt-driven
  communication. The main program will be interrupted to prioritize
  processing incoming data.
  
 */
#define DCSBIOS_DEFAULT_SERIAL

#include <Joystick.h>

Joystick_ Joystick;

#include "DcsBios.h"

int landingGearRedButton = 2; // Pin for button

/* paste code snippets from the reference documentation here */


DcsBios::LED landingGearRed(0x500e, 0x2000, LED_BUILTIN);

void setup() {
  DcsBios::setup();

  pinMode(landingGearRedButton, INPUT_PULLUP);

 Joystick.begin();
}

void loop() {
  DcsBios::loop();

 Joystick.setButton(1,!digitalRead(landingGearRedButton));
}

Program the Arduino, then connect it to DCS-BIOS.
Fire up DCS and start a TF-51D cold start instant action mission.
Press ESC and go to adjust controls.
You should see a column for your Arduino device.
Scroll down to "Landing Gear Unsafe Light Test", right click on the control box and "add combo".
Press the Arduino button, then click OK.  Go back to the cockpit and turn on the battery (right side panel).
The green landing gear light should illuminate.
Press the Arduino button, and the red light next to the green should come on, and the lamp surround presses in.
The built-in LED on the Arduino should come on as well.
Then press the Red indicator in the cockpit, and again, the cockpit and Arduino LEDs should light.

What you now have is an Arduino sending button presses as an HID, and receiving feedback from DCS via DCS-BIOS.
 

Edited by No1sonuk
  • Like 2
  • Thanks 1
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...