05 April 2021

Project: Game Controller


        This is the unofficial ShellShock Live game controller. A tank taken right out of the popular battle game turned into a unique controller that controls the movement, barrel angle, and shot power of the tank you control in game. A potentiometer that comes out of the top hatch controls the gun angle while two slide potentiometers, one on either side of the chassis, control the power and movement of the tank. A normal 3’ USB power cord comes out of the back so it's easy to connect it to any computer. All three potentiometers as well as the power cord are all connected to the Circuit Playground Express that is housed within the controller, by alligator clips and wires. With this controller, you get an extra sense of immersion while playing the game, as well as easier and more precise controls on where you want to shoot. It’s very easy to figure out how to use the potentiometers based on where and how they are located on the tank. The normal potentiometer just appears as a skinny knob that comes out of the very top of the tank, and only has twisting movement. The two slide potentiometers are housed right above the treads in a horizontal manner so it’s very easy to see they move parallel to said treads. Plus they only move back and forth so once you mess with them you instantly know. Due to the way all three of the potentiometers are built, they have stops so that you can only slide or spin them to a certain degree before having to go back. Together all these parts make it way more fun to play with than the regular keyboard controls that are normally used to play the game. What other indicators or signifiers could be added to make an easier experience for any random person who’s never seen this model?

 


 ///////////////////////

//    ShellShock     //

// Custom Controller //

///////////////////////


#include <Keyboard.h>

#include <Adafruit_Circuit_Playground.h>

#include <Adafruit_CircuitPlayground.h>


const int debounce = 10;

const int threshold = 500;


void setup() 

{

  CircuitPlayground.begin();

  pinMode(CPLAY_SLIDESWITCHPIN, INPUT_PULLUP);

  Keyboard.begin();

}


void loop() 

  //Potentiometer controlls angle of tank barrel

  int pot = analogRead(A2);

   if(pot > 100 && pot < 500)

  {

    Keyboard.write('A');

    delay(debounce);

  }

  else if(pot > 500 && pot < 900)

  {

    Keyboard.write('D');

    delay(debounce);

  }

  //Slide potentiometer controlls tank movement

  int pot2 = analogRead(A6);

  if(pot2 > 100 && pot2 < 500)

  {

    Keyboard.write(216);

    delay(debounce);

  }

  else if(pot2 > 500 && pot2 < 900)

  {

    Keyboard.write(215);

    delay(debounce);

  }

  //Slide potentiometer controlls power of shot

  int pot3 = analogRead(A4);

  if(pot3 > 100 && pot3 < 500)

  {

    Keyboard.write(218);

    delay(debounce);

  }

  else if(pot3 > 500 && pot3 < 900)

  {

    Keyboard.write(217);

    delay(debounce);

  }

  Serial.print(CircuitPlayground.readCap(A3));

  Serial.print("\t");

  Serial.println(analogRead(A2));

  Serial.println(analogRead(A4));

  Serial.println(analogRead(A6));

}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.