27 March 2021

Scaffolding: Progress Review

    This is a controller for ShellShock Live, a turn based tank destruction game with horizontal movement with angular and power shooting. My controller will be able to control those 3 aspects of the game so it's easier for the player to aim while having a cool controller to play with. As of this review, I have 2 concepts for the controller that will be decided on very soon. The first concept is a hinge based clamp with slide switches on each side of the clamp. The angle at which the hinge is pointing will control the angle of the tank barrel and the slide potentiometer switches will control movement and firepower. The second concept is an actual tank toy that houses a potentiometer to change the angle of the barrel and 2 slide potentiometer switches mounted to the chassis to control movement and power. I'm currently trying to figure out if it's possible to 3D model the hinge since it's custom, if not I will be making the tank controller.






/////////////////////////////////
//       ShellShock       //
// Custom Controller //
////////////////////////////////

#include <Keyboard.h>
#include <Adafruit_Circuit_Playground.h>
#include <Adafruit_CircuitPlayground.h>

const int debounce = 100;
const int threshold = 500;

void setup() 
{
  CircuitPlayground.begin();
  pinMode(CPLAY_SLIDESWITCHPIN, INPUT_PULLUP);
  pinMode(CPLAY_LEFTBUTTON, INPUT_PULLDOWN); //button A
  pinMode(CPLAY_RIGHTBUTTON, INPUT_PULLDOWN); //button B
  Keyboard.begin();
}

void loop() 
  //Turns controller on and off
  if(CircuitPlayground.readCap(A3) > threshold && digitalRead(CPLAY_SLIDESWITCHPIN))
  {
    Keyboard.write(' ');
    delay(debounce);
  }

  //Potentiometer controlls angle of tank barrel
  int pot = analogRead(A4);
  
   if(pot > 200 && pot < 400)
  {
    Keyboard.write('KEY_UP_ARROW');
    delay(debounce);
  }
  else if(pot > 400 && pot < 600)
  {
    Keyboard.write('KEY_DOWN_ARROW');
    delay(debounce);
  }

  //Slide potentiometer controlls tank movement
  int pot = analogRead(A6);
  
  if(pot > 200 && pot < 400)
  {
    Keyboard.write('D');
    delay(debounce);
  }
  else if(pot > 400 && pot < 600)
  {
    Keyboard.write('A');
    delay(debounce);
  }

  //Slide potentiometer controlls power of shot
  int pot = analogRead(A2);
  
  if(pot > 200 && pot < 400)
  {
    Keyboard.write('KEY_RIGHT_ARROW');
    delay(debounce);
  }
  else if(pot > 400 && pot < 600)
  {
    Keyboard.write('KEY_LEFT_ARROW');
    delay(debounce);
  }

  Serial.print(CircuitPlayground.readCap(A3));
  Serial.print("\t");
  Serial.println(analogRead(A2));
  Serial.println(analogRead(A6));
  
}


  1. What kind of tank would you like to see me pull apart and fill with electronics?
  2. What can I do to improve my code?

No comments:

Post a Comment

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