Dear reader,

This site finally got its much-needed overhaul. I tried to keep existing pages at their original URLs.
Should you find an error, please do tell me at contact@aspyct.org.
Feel free to visit the new website, which may contain more documentation pertaining to your search.

Thank you for visiting aspyct.org, I hope you'll find what you're looking for.

Old Aspyct.org blog

 or  go to the new site.

Spitfire project, day #1

So we moved in with a few friends. A bunch of geeks just like me… fine move :) We call our house the “Geekarium”. And of course, we play video games. Or more specifically, we play War Thunder, a WW2 airplane simulation.

I like to pretend these planes are real, and the keyboard is not enough. Arduino to the rescue :)

A bit of history

The Supermarine Spitfire is probably one of the best known aircraft out there. A legend, dare I say.

Created a bit before WW2, the Spitfire was used along the Hurricane during the Battle of Britain, to successfully deflect german bombers.

It was fitted with a Merlin engine and beautiful elliptical wings, which made him very recognisable among the other airplanes.

Read more about this masterpiece of history on its wikipedia page.

So I started building this panel…

So yes, I’ve fallen in love again with airplanes. So much that I actually decided to supplement my joystick with a custom control panel. You know, for all those things that usually remain on the keyboard: start engine, landing gear control, flaps etc.

No blueprints yet, only experimenting some stuff with my arduino. Roughly, what I came up with until now is a sketch that monitors one or more digital inputs, and reports on the serial port.

Also available on github: https://github.com/aspyct/spitfire.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#define INPUT_COUNT 2
#define TIMEGUARD 100 // numper of milliseconds before a new input is taken into account

int inputs[INPUT_COUNT] = {
  2,
  6
};

int states[INPUT_COUNT];

char keymap[INPUT_COUNT * 2] = {
  'd', 'g',
  '6', '\0'
};

unsigned long fired[INPUT_COUNT];

void setup() {
  Serial.begin(9600);

  for (int i = 0; i < INPUT_COUNT; ++i) {
    pinMode(inputs[i], INPUT);
    states[i] = readState(inputs[i]);
    fired[i] = 0;
  }

  // Wait for serial connection to be established
  while (!Serial);
}

int readState(int pin) {
  return digitalRead(pin);
}

void loop() {
  for (int i = 0; i < INPUT_COUNT; ++i) {
    unsigned long time = millis();

    int pin = inputs[i];
    int val = readState(pin);

    if (val != states[i] && time - fired[i] > TIMEGUARD) {
      states[i] = val;
      fired[i] = time;

      char response = keymap[i * 2 + (val == HIGH)];
      if (response) {
        Serial.print(response);
      }
    }
  }
}

To be continued

As you can see, this is far from finished… Read the post for day #2.