Kerbal Space Program: 10 Axis Controller with Arduino Mega.

by Declan Heard

How about a custom 10 Axis Controller?

Kerbal Space Program is a brilliant game/Space Flight Simulator, it teaches the basics of rocket science, and aerodynamics, and lets you test out crazy contraptions that only exist in science fiction and never before realised concepts.

The scope for this project was to replace the typical keyboard game controls, with a far more interactive, intuitive and fun Analogue Stick control layout. I wanted to be able to assign different controls depending on whether a Rocket is being flown to orbit, a Spaceplane was lining up on final approach to a runway, or a Rover was being driven across the surface of The Mun.

The controller runs off an Arduino Mega 2560 and uses the Kerbal SimPit Mod installed in the Game Data folder of Kerbal Space Program. The ready-made Arduino library, Kerbal SimPit is available from the Arduino Library Manager, and this handles all the communication between the controller and the game.


As well as the typical flight controls, Pitch, Yaw, and Roll, the controller also handles translation controls, i.e. movement in the X, Y and Z direction when the Reaction Control Thrusters (RCS) are enabled and Rover Wheel commands, Throttle and Steering when in Rover Mode.

To be able to control each of these parameters in unison, I used two 3 axis joysticks that would operate most of the main flight controls, and two 2 axis joysticks to cover rudders in plane mode and some of the RCS translation controls. This is way more options than is really needed, but it gives the pilot scope to adapt the controls to suit different vehicles and flying styles.

A simple slide pot enables fine control of the Main Engine Throttle, which makes precise landing burns easy and fun to pull off. No more need for parachutes, just make sure you have enough fuel to complete your suicide burn!

A large Staging button in the centre of the console takes the place of the spacebar. Press this button to go to space. Always make sure you check your staging before hitting the go button.

Once underway, its often prudent to lock the staging button until it is required again. A handy toggle switch is provided to lock the staging button, ensuring your rocket doesn’t break into different pieces at an inopportune moment.  

The other switches let the pilot raise and lower the gear, apply brakes, toggle SAS (Stability) and RCS modes, or trigger any of 10 or 20 different custom actions depending on which other mods you have installed.

Of course, any Rocket is incomplete without some way of aborting the flight and saving the cosmonauts when everything is going wrong. In case of RUD, Rapid Unscheduled Disassembly, pressing and holding the Abort Switch prompts the pilot to press the stage button to engage Abort Mode.

Once Abort Mode is engaged, there is no turning back. If you have set it up your actions correctly, your crew capsule separates, the abort motors fire, and your crew is dragged, kicking and screaming away from any impending explosions, and..…are safe. You remembered to pack parachutes, right?


On boot up, if the Arduino finds a config file saved to the CD card it applies the last saved settings, if it cannot find a file it boots with factory settings, and creates a config file to save settings into. It then runs a self-calibration to make sure all the joysticks are outputting zero.

The OLED screen displays various actions, like which SAS mode has been triggered, and the status of Brakes and the Gear. It also lets budding Astronauts change and save the different options for each of the flight modes, Rocket, Plane and Rover, run the calibration routine, and set the SD card to restore the factory config file on bootup.

The front panel was designed in Fusion 360, and 3D printed to fit an off the shelf Hammond, although this version was measured slightly inaccurately and required a small amount of filing to get some parts to fit.

The wiring was planned using DIY Layout Creator, I wanted every connection on header pins, allowing easy maintenance and future expansion or improvements. All the power, GND and Signal wire to and from the front panels, including pull up and pull-down resistors would be over two daughterboards.

Organised Chaos. Imagine how it would look without planning.


Due to the limitations of the mod and the game functions, several of the switches for the SAS autopilot do not function as well as hoped and occasionally cause the game to crash when operated.

These controls are also assigned to the keyboard numpad, so a second controller could be used to handle these commands, as well as some other keyboard shortcuts the game relies on, like changing camera views and controlling the time warp functions. This could run on an Arduino Leonardo, which would show up as a keyboard or Joystick input to the computer.

I would really like to improve the front panel, possibly make it into a single PCB that can have the control labels silkscreened directly on. This could also save all of the offboard wiring, and a single ribbon cable used to connect the Arduino to the front panel.

For the source code for this project, see my GitHub repo @:

Full instructional writeup due at some point.

Controlling 2 LEDs with 1 pin

Not many people know that it is possible to control 2 LEDs individually with just a single digital output pin. See the video below for proof. These 2 LEDs are both connected to the same pin, digital pin D5 on a Wemos D1 mini.

How is this magic possible? Take a look at the circuit diagram. As you can see we have both of the LEDs connected to the same digital pin. However, one LED has its cathode (negative leg) connected to ground and the other one is connected to 5v (or 3v on a Wemos D1).

To light up LED 1, make the digital pin an output and make the pin HIGH. Electricity will flow from the digital pin to ground, lighting up LED 1. To light up LED 2, make the digital pin go LOW. Now the electricity will flow from the 5v (0r 3,3v) pin to ground via the digital pin that has been pulled low.

To turn both LEDs off, make the digital pin an INPUT, which will prevent the voltage from going anywhere and both LEDs now turn off.

So, how do you light up both LEDs? Well, it is not possible. However, you can trick your eye into seeing they are both on by turning each LED on in quick succession very very fast.

Take a look at the entire code below and you will see how to turn both LEDs on at the same time in the do…while loop.

unsigned long counter;

void setup() {
    pinMode(D5, OUTPUT);

void loop() {
    // Turn LED A on B off
    pinMode(D5, OUTPUT);
    digitalWrite(D5, HIGH);

    // Turn LED B on A off
    digitalWrite(D5, LOW);

    // Turn LED A and B on (very fast)
    counter = millis();

        digitalWrite(D5, HIGH);
        digitalWrite(D5, LOW);
    } while ((millis() - counter) < 1000);

    // Turn LED A and B off
    pinMode(D5, INPUT);

The only disadvantage to this is when both LEDs are apparently on they re slightly dimmer then when on individually. However, for the sake of saving 50% of he number of pins this is a small trade-off.

Making an Arduino based Simon Game

So we decided at |Medway Makers to do a little collaborative project and to do a workshop on building and coding a ‘Simon’ game.

This was mainly born out of a complaint from Tom that he had bought a mini Simon Game and that it was not the same game he remembered as a kid. So, we decided let’s build our own.

Arduino based Simon

We used an Arduino Nano, 4 large buttons with clear caps and 4 LEDs, plus piezo buzzer for the tunes. The circuit is really simple with pull down resistors on each button and current limiting resistors on each LED.

The code creates a random note selected from 4 possible notes and adds it to an array. The note is then played and the corresponding LED is lit. The player then has to press the appropriate button to match the note. If he succeeds, another random note is chosen, added to the array and the tune played so far. This is repeated for as long as the player is able to remember the sequence. The speed of the tune being played back is also increased slightly in each round until eventually it will become impossible

The code plus the circuit for this project can be found on Mike’s Github HERE.

Check out this video for the game in action.

Website Built with

Up ↑