Jump to content

F5E Armament Panel with Arduino Leonardo


JNinness

Recommended Posts

Hi All,

 

I love flying DCS and in particular multiple air frames. I admire the work that many on these forums have put into their Sim Pits and I do regard many of them with Envy, alas with young children I simply do not have the space for a full sim pit. I have instead worked on a more modular approach.

 

So I have completed my first "Modular" Sim Pit Idea. This was the F5E Armament Panel. This panel was chosen due to the manual activation that are required for the delivery of ordnance. The requirements for the panel were that it had to be easy to setup and pack away, and not require third party software to function with DCS.

 

I ended up settling on the Arduino Leonardo. Due to the limited space on the assembly box I chose I did have to make a tiny alteration on button and switch placement on the missile volume control and on the selective jettison. I also had to replace the 4 position toggle switch to a rotary switch.

 

Build time ended up being 3 days, however I had some experience with C++ programming from high school (That was 18 years ago though) and have experimented with inputs and outputs from Arduino and into the computer previously.

 

As my wife has pointed out to me however I didn't take any pictures of me actually building the panel so it is not the best how to guide, sorry for that.

 

So to make it up to those interested I have included the Arduino code below. and a link to the Youtube video will be added once it has uploaded.

 

Happy flying! :pilotfly:

"Jonno"

 

Flying DCS since Black Shark 1.

Link to comment
Share on other sites

/*

This program is designed to emulate the Armament Panel in the F5E-3 for DCS, Utilizing an Arduino Leonardo. Written by John Ninness

*/

#include <Joystick.h>

#include <Keyboard.h>

#include "Keyboard.h"

 

Joystick_ Joystick;

 

//Variables

//Input digital pins (unchanging)

const int Master_Control = 0;

const int Left_Wing_Station = 1;

const int Left_Out_Station = 2;

const int Left_In_Station = 3;

const int Centre_Station = 4;

const int Right_In_Station = 5;

const int Right_Out_Station = 6;

const int Right_Wing_Station = 7;

const int Bomb_Interval_Up = 9;

const int Bomb_Interval_Down = 8;

const int Guns_Missiles = 11;

const int Camera = 10;

const int Jettison_Switch_Up = 13;

const int Jettison_Switch_Down = 12;

//Input analogue pins (unchanging)

int Missile_Volume = A0;

int Fuse_Selector = A2;

int Stores_Selector = A1;

int Jettison_Selector = A3;

//Input analogue values (changing)

int Missile_Volume_Val = 0;

int Fuse_Selector_Val = 0;

int Fuse_Selector_Last_Val = 0;

int Stores_Selector_Val = 0;

int Stores_Selector_Last_Val = 0;

int Jettison_Selector_Val = 0;

//Input digital pins state (changing)

int Master_Control_State = 0;

int Left_Wing_Station_State = 0;

int Left_Out_Station_State = 0;

int Left_In_Station_State = 0;

int Centre_Station_State = 0;

int Right_Wing_Station_State = 0;

int Right_Out_Station_State = 0;

int Right_In_Station_State = 0;

int Bomb_Interval_Up_State = 0;

int Bomb_Interval_Down_State = 0;

int Guns_Missiles_State = 0;

int Camera_State = 0;

int Jettison_Switch_Up_State = 0;

int Jettison_Switch_Down_State = 0;

 

//Input analogue pins state (changing)

 

//Assigned keys variables (in ASCII Code)

char LCtl = 128;

char LShf = 129;

char LAlt = 130;

char LWin = 131;

char RCtl = 132;

char RShf = 133;

char RAlt = 134;

char RWin = 135;

 

void setup()

{

Joystick.begin();

 

pinMode(Master_Control, INPUT_PULLUP);

pinMode(Left_Wing_Station, INPUT_PULLUP);

pinMode(Left_Out_Station, INPUT_PULLUP);

pinMode(Centre_Station, INPUT_PULLUP);

pinMode(Left_In_Station, INPUT_PULLUP);

pinMode(Right_Wing_Station, INPUT_PULLUP);

pinMode(Right_Out_Station, INPUT_PULLUP);

pinMode(Right_In_Station, INPUT_PULLUP);

pinMode(Bomb_Interval_Up, INPUT_PULLUP);

pinMode(Bomb_Interval_Down, INPUT_PULLUP);

pinMode(Guns_Missiles, INPUT_PULLUP);

pinMode(Camera, INPUT_PULLUP);

pinMode(Jettison_Switch_Up, INPUT_PULLUP);

pinMode(Jettison_Switch_Down, INPUT_PULLUP);

 

Keyboard.begin();

}

 

void loop()

{

while (digitalRead(Master_Control) == LOW)

{

Missile_Volume_Val = analogRead(Missile_Volume);

Missile_Volume_Val = map(Missile_Volume_Val, 0, 1023, 0, 255);

Joystick.setZAxis(Missile_Volume_Val);

 

Fuse_Selector_Val = map(analogRead(Fuse_Selector), 0, 700, 0, 4);

Stores_Selector_Val = map(analogRead(Stores_Selector), 0, 700, 0, 4);

Jettison_Selector_Val = map(analogRead(Jettison_Selector), 0, 700, 0, 7);

 

if (Fuse_Selector_Val < Fuse_Selector_Last_Val)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press(93);

delay(1);

Fuse_Selector_Last_Val = Fuse_Selector_Val;

Keyboard.release(93);

Keyboard.release(LShf);

Keyboard.release(LCtl);

} else if (Fuse_Selector_Val > Fuse_Selector_Last_Val)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press(91);

delay(1);

Fuse_Selector_Last_Val = Fuse_Selector_Val;

Keyboard.release(91);

Keyboard.release(LShf);

Keyboard.release(LCtl);

}

 

if (Stores_Selector_Val < Stores_Selector_Last_Val)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('e');

delay(1);

Stores_Selector_Last_Val = Stores_Selector_Val;

Keyboard.release(LCtl);

Keyboard.release(LShf);

Keyboard.release('e');

} else if (Stores_Selector_Val > Stores_Selector_Last_Val)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('w');

delay(1);

Stores_Selector_Last_Val = Stores_Selector_Val;

Keyboard.release('w');

Keyboard.release(LShf);

Keyboard.release(LCtl);

}

 

if (Jettison_Selector_Val == 5)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('9');

delay(50);

Keyboard.release('9');

delay(250);

Keyboard.press('0');

while (Jettison_Selector_Val == 5)

{

Jettison_Selector_Val = map(analogRead(Jettison_Selector), 0, 700, 0, 7);

delay(1);

}

Keyboard.release('0');

Keyboard.release(LShf);

Keyboard.release(LCtl);

} else if (Jettison_Selector_Val == 6)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('d');

while (Jettison_Selector_Val == 6)

{

Jettison_Selector_Val = map(analogRead(Jettison_Selector), 0, 700, 0, 7);

delay(1);

}

Keyboard.release('d');

Keyboard.release(LShf);

Keyboard.release(LCtl);

}

 

if (digitalRead(Left_Wing_Station) == LOW & Left_Wing_Station_State == 0)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('1');

delay(1);

Left_Wing_Station_State = 1;

Keyboard.release(LCtl);

Keyboard.release(LShf);

Keyboard.release('1');

} else if (digitalRead(Left_Wing_Station) == HIGH & Left_Wing_Station_State == 1)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('1');

delay(1);

Left_Wing_Station_State = 0;

Keyboard.release('1');

Keyboard.release(LShf);

Keyboard.release(LCtl);

}

 

if (digitalRead(Left_Out_Station) == LOW & Left_Out_Station_State == 0)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('2');

delay(1);

Left_Out_Station_State = 1;

Keyboard.release('2');

Keyboard.release(LShf);

Keyboard.release(LCtl);

} else if (digitalRead(Left_Out_Station) == HIGH & Left_Out_Station_State == 1)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('2');

delay(1);

Left_Out_Station_State = 0;

Keyboard.release('2');

Keyboard.release(LShf);

Keyboard.release(LCtl);

}

 

if (digitalRead(Left_In_Station) == LOW & Left_In_Station_State == 0)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('3');

delay(1);

Left_In_Station_State = 1;

Keyboard.release(LCtl);

Keyboard.release(LShf);

Keyboard.release('3');

} else if (digitalRead(Left_In_Station) == HIGH & Left_In_Station_State == 1)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('3');

delay(1);

Left_In_Station_State = 0;

Keyboard.release('3');

Keyboard.release(LShf);

Keyboard.release(LCtl);

}

 

if (digitalRead(Centre_Station) == LOW & Centre_Station_State == 0)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('4');

delay(1);

Centre_Station_State = 1;

Keyboard.release('4');

Keyboard.release(LShf);

Keyboard.release(LCtl);

} else if (digitalRead(Centre_Station) == HIGH & Centre_Station_State == 1)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('4');

delay(1);

Centre_Station_State = 0;

Keyboard.release('4');

Keyboard.release(LShf);

Keyboard.release(LCtl);

}

 

if (digitalRead(Right_In_Station) == LOW & Right_In_Station_State == 0)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('5');

delay(1);

Right_In_Station_State = 1;

Keyboard.release(LCtl);

Keyboard.release(LShf);

Keyboard.release('5');

} else if (digitalRead(Right_In_Station) == HIGH & Right_In_Station_State == 1)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('5');

delay(1);

Right_In_Station_State = 0;

Keyboard.release('5');

Keyboard.release(LShf);

Keyboard.release(LCtl);

}

 

if (digitalRead(Right_Out_Station) == LOW & Right_Out_Station_State == 0)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('6');

delay(1);

Right_Out_Station_State = 1;

Keyboard.release('6');

Keyboard.release(LShf);

Keyboard.release(LCtl);

} else if (digitalRead(Right_Out_Station) == HIGH & Right_Out_Station_State == 1)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('6');

delay(1);

Right_Out_Station_State = 0;

Keyboard.release('6');

Keyboard.release(LShf);

Keyboard.release(LCtl);

}

 

if (digitalRead(Right_Wing_Station) == LOW & Right_Wing_Station_State == 0)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('7');

delay(1);

Right_Wing_Station_State = 1;

Keyboard.release(LCtl);

Keyboard.release(LShf);

Keyboard.release('7');

} else if (digitalRead(Right_Wing_Station) == HIGH & Right_Wing_Station_State == 1)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('7');

delay(1);

Right_Wing_Station_State = 0;

Keyboard.release('7');

Keyboard.release(LShf);

Keyboard.release(LCtl);

}

 

if (digitalRead(Bomb_Interval_Up) == LOW & Bomb_Interval_Up_State == 0)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('q');

delay(1);

Bomb_Interval_Up_State = 1;

Keyboard.release('q');

Keyboard.release(LShf);

Keyboard.release(LCtl);

} else if (digitalRead(Bomb_Interval_Up) == HIGH & Bomb_Interval_Up_State == 1)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('a');

delay(1);

Bomb_Interval_Up_State = 0;

Keyboard.release('a');

Keyboard.release(LShf);

Keyboard.release(LCtl);

}

 

if (digitalRead(Bomb_Interval_Down) == LOW & Bomb_Interval_Down_State == 0)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('a');

delay(1);

Bomb_Interval_Down_State = 1;

Keyboard.release('a');

Keyboard.release(LShf);

Keyboard.release(LCtl);

} else if (digitalRead(Bomb_Interval_Down) == HIGH & Bomb_Interval_Down_State == 1)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('q');

delay(1);

Bomb_Interval_Down_State = 0;

Keyboard.release('q');

Keyboard.release(LShf);

Keyboard.release(LCtl);

}

 

if (digitalRead(Jettison_Switch_Up) == LOW & Jettison_Switch_Up_State == 0)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('s');

delay(1);

Jettison_Switch_Up_State = 1;

Keyboard.release('s');

Keyboard.release(LShf);

Keyboard.release(LCtl);

} else if (digitalRead(Jettison_Switch_Up) == HIGH & Jettison_Switch_Up_State == 1)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('f');

delay(1);

Jettison_Switch_Up_State = 0;

Keyboard.release('f');

Keyboard.release(LShf);

Keyboard.release(LCtl);

}

 

if (digitalRead(Jettison_Switch_Down) == LOW & Jettison_Switch_Down_State == 0)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('f');

delay(1);

Jettison_Switch_Down_State = 1;

Keyboard.release('f');

Keyboard.release(LShf);

Keyboard.release(LCtl);

} else if (digitalRead(Jettison_Switch_Down) == HIGH & Jettison_Switch_Down_State == 1)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('s');

delay(1);

Jettison_Switch_Down_State = 0;

Keyboard.release('s');

Keyboard.release(LShf);

Keyboard.release(LCtl);

}

 

if (digitalRead(Guns_Missiles) == LOW & Guns_Missiles_State == 0)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('t');

delay(50);

Keyboard.release('t');

delay(50);

Keyboard.press('g');

delay(50);

Guns_Missiles_State = 1;

Keyboard.release('g');

Keyboard.release(LCtl);

Keyboard.release(LShf);

} else if (digitalRead(Guns_Missiles) == HIGH & Guns_Missiles_State == 1)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('b');

delay(50);

Keyboard.release('b');

delay(50);

Keyboard.press('t');

delay(50);

Guns_Missiles_State = 0;

Keyboard.release('t');

Keyboard.release(LCtl);

Keyboard.release(LShf);

}

 

if (digitalRead(Camera) == LOW & Camera_State == 0)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('t');

delay(50);

Keyboard.release('t');

delay(50);

Keyboard.press('b');

delay(50);

Camera_State = 1;

Keyboard.release('b');

Keyboard.release(LCtl);

Keyboard.release(LShf);

} else if (digitalRead(Camera) == HIGH & Camera_State == 1)

{

Keyboard.press(LCtl);

Keyboard.press(LShf);

Keyboard.press('g');

delay(50);

Keyboard.release('g');

delay(50);

Keyboard.press('t');

delay(50);

Camera_State = 0;

Keyboard.release('t');

Keyboard.release(LCtl);

Keyboard.release(LShf);

}

 

delay(100);

}

}

"Jonno"

 

Flying DCS since Black Shark 1.

Link to comment
Share on other sites

Thanks!

 

Here is my full setup. I call it the dad on a budget! The monitor is on a wall mounted swing arm so I can switch between flying and working on the same machine easily.

 

89441077748e8f2d10ee91f58a77d60f.jpg59524f7c579acf319d893841c76495a8.jpg9691b94fce6afb5005e1b8ecaa7077bd.jpg

 

Sent from my SM-G930F using Tapatalk

"Jonno"

 

Flying DCS since Black Shark 1.

Link to comment
Share on other sites

The design looks quite similar to Harrier´s, interesting

i5 8400 | 32 Gb RAM | RTX 2080Ti | Virpil Mongoose T-50 base w/ Warthog & Hornet sticks | Warthog throttle | Cougar throttle USB | DIY Collective | Virpil desk mount | VKB T-Rudder Mk IV | Oculus Rift S | Buddy-Fox A-10 UFC | 3x TM MFDs | 2x bass shakers pedal plate| SIMple SIMpit chair | WinWing TakeOff panel | PointCTRL v2 | Andre JetSeat | Winwing Hornet UFC | Winwing Viper ICP

FC3 - Warthog - F-5E - Harrier - NTTR - Hornet - Tomcat - Huey - Viper - C-101 - PG - Hip - SuperCarrier - Syria - Warthog II - Hind - South Atlantic - Sinai - Strike Eagle

Link to comment
Share on other sites

I noticed the switch safety cover wasn’t wired into the Arduino... I remember seeing a cockpit (possibly here on DCS forums) where the owner had the switch cover connected by a wire (a small thin metal bar..?) so that when the red cover was opened or closed, a switch would be activated or de-activated, which opened/closed the in-game cover via the Arduino. (An A-10 cockpit, iirc)

 

Just an idea if you’re interested.

Link to comment
Share on other sites

  • 2 months later...
I noticed the switch safety cover wasn’t wired into the Arduino... I remember seeing a cockpit (possibly here on DCS forums) where the owner had the switch cover connected by a wire (a small thin metal bar..?) so that when the red cover was opened or closed, a switch would be activated or de-activated, which opened/closed the in-game cover via the Arduino. (An A-10 cockpit, iirc)

 

Just an idea if you’re interested.

Yeah,

 

It can be achieved with a microswitch monitoring the cover I did think about it but ultimately decided against it as it would need another input of it's own.

 

Sent from my SM-G930F using Tapatalk

"Jonno"

 

Flying DCS since Black Shark 1.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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