Introduction: MF DOOM Video Game Controller

For this school project I made a video game controller that you can connect to Unity and play a little racing game. The controller was inspired by another school project I worked on where you played as MF DOOM. The end scene was him racing away from some bad guys. This inspired the controller itself and the game you play it with. When making this project I sometimes got frustrated because when you migrate from breadboard to perfboard you basicly need to redo your design to work with perfboard. I skipped this step and it made it a bit harder in the end to work with the improvised design I went with. Namely the reliability was a bit of an issue.

Supplies

Circuit:

  • Arduino Uno
  • Force Sensing Resistor 0,5"
  • 2 red Leds 5mm
  • 1 orange Led 5mm
  • 1 yellow Led 5mm
  • 2 green Leds 5mm
  • 8x 10k ohm resistors
  • 100k Potentiometer
  • Joystick Module
  • Pushbutton
  • Perfboard
  • Wires

Enclosure:

  • Lasercut wood
  • Glue

Tools:

  • Soldering iron
  • Soldering tin
  • Utility knife

Step 1: Breadboard Design

Before I could start with this project I needed a design I could work off of. I prototyped my design on a breadboard wich resulted in the design above. It is a fairly simple design because everything just needs power and input from the arduino. This breadboard design also allowed me to begin working on the code to make it working, and to work on the Unity project.

The controller works as follows:

The joystick just has the X/Y movement, And when you push it in, you activate a speedboost.

The FSR senses the force you put on it, this translates into the height/force you jump with.

The Potentiometer acts as an throttle lever and the LEDS indicate how much throttle you put in

Lastly the little pushbutton acts as an engine starter.


//Setup initial variables
int value = 0;
int led1=4,led2=5,led3=6,led4=7, led5=8, led6=9;
bool started = true;


void setup() 
{
  //Setup input modes of the used pins
  pinMode(A0, INPUT);
  pinMode(A1, INPUT);
  pinMode(A2, INPUT);
  pinMode(A3, INPUT);
  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(led1,OUTPUT);
  pinMode(led2,OUTPUT);
  pinMode(led3,OUTPUT);
  pinMode(led4,OUTPUT);
  pinMode(led5,OUTPUT);
  pinMode(led6,OUTPUT);


  //Sets the on/off led to High when the arduino is powered
  digitalWrite(led6,HIGH);


  Serial.begin(9600);
}
void loop() 
{
  //Main loop


  //Handle starting sequence 
  StartingSequence();
  //Handles the LED logic of the amount of throttle given
  HandleLeds();


  //Starts the loop when the game is started
  if(started)
  {
    //Send the raw data to Unity
    SendMSG();
  }
  else
  {
    //Send fixed data to Unity
    Send0();
  }


  delay(10);
}


//Only start the car when a certain value of throttle is reached and the start button is engaged
void StartingSequence()
{
  if(digitalRead(3) == 1 && analogRead(A3) >= 500)
  {
    started = true;
  }
  else if(analogRead(A3) <= 100)
  {
    started = false;
  }
}


//Sends zeroed out data to Unity. Giving the player no input or ability to control the car
void Send0()
{
  Serial.print(512, DEC);
  Serial.print("|");
  Serial.print(512, DEC);
  Serial.print("|");
  Serial.print(1, DEC);
  Serial.print("|");
  Serial.print(0, DEC);
  Serial.print("|");
  Serial.print(0, DEC);
  Serial.print("|");
  Serial.println(digitalRead(10), DEC);
}


//Sends all the Data from the sensors and splits them with: |, In unity this message is parsed on that character
void SendMSG()
{
  value = analogRead(A0);
  Serial.print(value, DEC);


  value = analogRead(A1);
  Serial.print("|");
  Serial.print(value, DEC);


  value = digitalRead(2);
  Serial.print("|");
  Serial.print(value, DEC);
 
  value = analogRead(A2);
  Serial.print("|");
  Serial.print(value, DEC);


  value = analogRead(A3);
  Serial.print("|");
  Serial.println(value, DEC);
}


//Sets the LEDS HIGH or LOW depending on the mapped value of the Potentiometer
void HandleLeds()
{
  int sensorValue=analogRead(A3);
  sensorValue=map(sensorValue,0,1023,0,5);


  if (sensorValue==0)
  {
    digitalWrite(led1,LOW);
    digitalWrite(led2,LOW);
    digitalWrite(led3,LOW);
    digitalWrite(led4,LOW);
    digitalWrite(led5,LOW);
  }


  if (sensorValue==1)
  {
    digitalWrite(led1,HIGH);
    digitalWrite(led2,LOW);
    digitalWrite(led3,LOW);
    digitalWrite(led4,LOW);
    digitalWrite(led5,LOW);
  }


  if (sensorValue==2)
  {
    digitalWrite(led1,HIGH);
    digitalWrite(led2,HIGH);
    digitalWrite(led3,LOW);
    digitalWrite(led4,LOW);
    digitalWrite(led5,LOW);
  }


  if (sensorValue==3)
  {
    digitalWrite(led1,HIGH);
    digitalWrite(led2,HIGH);
    digitalWrite(led3,HIGH);
    digitalWrite(led4,LOW);
    digitalWrite(led5,LOW);
  }


  if (sensorValue==4)
  {
    digitalWrite(led1,HIGH);
    digitalWrite(led2,HIGH);
    digitalWrite(led3,HIGH);
    digitalWrite(led4,HIGH);
    digitalWrite(led5,LOW);
  }


  if (sensorValue==5)
  {
    digitalWrite(led1,HIGH);
    digitalWrite(led2,HIGH);
    digitalWrite(led3,HIGH);
    digitalWrite(led4,HIGH);
    digitalWrite(led5,HIGH);
  }
}

Step 2: Enclosure Design

Next step was to design the enclosure. I did this in Fusion360 with the sketch function. I designed slots for certain parts like the FSR to sit flush on the wood. This way I was able to layer it without weird gaps in between. It took me 2 tries to get to a pretty decent design that would work for me. For example in the first iteration every layer was glued together this caused it to shift and make it not flush with each other. I solved this by adding a few pins through the layers that keeps everything level and flush. Then I ran it through LaserWorkV6 to add all the designated line properties. This way the Lasercutter would interpret what lines to cut and wich areas to etch out.

Step 3: Making the Enclosure

This step started out with laser cutting the wood and assembling everything using glue. The layers were glued together and fixed to the front. With the back consisting of 2 layers, One blank and one with cutouts for the arduino, support posts to slot into, a few slots for the cable to connect it to the computer and one for supporting the potmeter.

Step 4: Soldering

I soldered the seperate components together on their own breakout boards. This was then connected to a main power board where all the 5v and ground where centralized. Then everything was connected to the arduino

Step 5: Testing and Finalizing

https://youtu.be/0HCCr6cpHNw

Then it was finally done. After a few hiccups along the way and fixing some issues regarding loose cables etc. It all was fixed in the end and that led to it working!


This was my project, hope you enjoyed! :D