Skip to content
MrBuzzKillington edited this page Oct 31, 2021 · 7 revisions

Software required to use DCS-bios Arduino library

Hardware required

  • Arduino UNO or MEGA
  • Switches, LEDS, etc
  • Wire

Knowledge required

  • Basic Arduino programming (or willingness to learn)
  • Basic wiring
  • Patience :)

Install Steps

  1. Make sure you have opened both DCS and Arduino tools to ensure library paths are generated
  2. Git checkout both the LUA and Arduino files into your "my documents"
  1. Configure DCS-BIO (follow tutorial on Flight Panels Wiki)
  • Copy folder dcs-bios->scripts->DCS-BIOS into your saved games folder C:\Users\USERNAME\Saved Games\DCS\scripts\
  • Copy Export.lua into C:\Users\USERNAME\Saved Games\DCS\scripts\
  1. Extract SOCAT
  • Extract socat tools from dcs-bios->program->socat
  • Verify connect serial port icon opens a socat terminal, double click dcs-bios/programs->connect-serial-port.cmd
  1. Install Arduino library (from git checkout)
  • Copy folder dcs-bios-arduino-library to C:\Users__\Documents\Arduino\libraries
    Note 1: There is a copy of this library in the dcs-bios repo but it may be out of date from latest
    Note 2: Many DCS-BIOS status variables tie directly to memory addresses within the game. Your DCS, DCS-BIOS, and Arduino code need to stay in sync, if you update DCS expect to update DCS-BIOS lua and Arduino code.

Making your first sketch

  1. Open control-ref documents using web browser via
    file:///C:/Users/USERNAME/Saved%20Games/DCS/scripts/DCS-BIOS/doc/control-reference.html
  2. Open Arduino IDE
  3. Paste Default template
#define DCSBIOS_DEFAULT_SERIAL

#include "DcsBios.h"

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

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

void loop() {
  DcsBios::loop();
}
  1. Compile and upload to board with => icon
    Congratulations you made your first DCS-BIOS Arduino script, now lets make it do something useful and test it

Adding a switch and LED

Each aircraft has unique hardware settings, using the control-reference.html find the available commands
For this example we will use the F-16C Block 50 module by selecting F-16C_50 from the module drop-down

  1. Copy and past the example source code for the signal to be controlled into your project above void setup() where indicated
DcsBios::Switch2Pos seatEjectSafe("SEAT_EJECT_SAFE", PIN);
DcsBios::LED lightSeatNot(0x4472, 0x0400, PIN);
  1. Specify the PIN number tied to your switch or LED (Wiring Basics and Examples)
/*
     Simple Example  
*/
#define DCSBIOS_DEFAULT_SERIAL

#include "DcsBios.h"


DcsBios::Switch2Pos seatEjectSafe("SEAT_EJECT_SAFE", 53);
DcsBios::LED lightSeatNot(0x4472, 0x0400, LED_BUILTIN);


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

void loop() {
  DcsBios::loop();
}
  1. Compile and upload to Arduino
  2. Start serial port forwarding
    SOCAT converts the Arduino serial port interface to ethernet packets which the LUA mod listens for
  • Run SOCAT program via shortcut (connect-serial-port.cmd)
  • Enter serial port number for connected Arduino
  • After the timeout expires, toggle the switch and verify SEAT_EJECT_SAFE commands are observed
  1. Start DCS -> Enter cockpit (instant action -> ready on ramp)
  • Toggle seat arm switch and verify both in-game switch and Arduino LED operate
  1. You can repeat these steps for all available controls in DCS
    Note 1: You do NOT need to close DCS in order to modify your Arduino design
    Note 2: You DO need to close SOCAT in order to reprogram the Arduino