27 November 2023

Pong Final Controller

 Griffin Shields

The goal of my piece is to make a heavily thematic controller for the game Pong. One of the cornerstones of my design is that I'm not trying to make a controller that is good or the best way to play Pong, or even make a controller that's easy to use, and I’m comfortable sacrificing that to keep the theming and entertainment factor. Throwing a ping pong ball (with a bounce, required with normal Beer Pong rules) into one of the cups successfully will activate the pressure sensor inside. Four total inputs, one for continuous up, one for continuous down, and these are for crossing the whole screen, along with a third and fourth input, for taking the Pong paddle part way up, and part way down, respectively. The conceptual model of my design is using successful Cup Pong hits to control the video game Pong, with the options dependent on the cup. This also allows the wires to be visible, as the cups should be mostly freestanding and moveable like in Cup Pong. The input is throwing the ping pong balls, to which the output is where they land- which is activating the REAL input, the pressure sensors, and their output is the Up/Down in Pong. The feedback is both the game changing, along with seeing the balls roll back to the player upon a successful hit. The game affords the player a goofy and non optimal way to play Pong that is highly spirited and thematic. Are there better options I could have picked for the 4 inputs, with the knowledge pong is a two input game bar menus navigation?



   copy and paste into browser


#include <Servo.h> //how to select one from multiple libraries?
#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>
#include <Keyboard.h>
// connect servo brown to ground
// connect servo red to 3.3v
// connect servo yellow CPE/B A3

//Servo myServo;
const int debounce = 200;
bool goingUp = false;
bool goingDown = false;

void setup() {
 // put your setup code here, to run once:
 Serial.begin(9600);
 delay(0);
 CircuitPlayground.begin();
 Keyboard.begin();
}

void loop() {
 
  if(1000 < CircuitPlayground.readCap(A7)){
    goingUp = false;
    Serial.println("switched to down");
    goingDown = true;
  }
  if (goingDown){
    //do go down input
    Serial.println("down");
    Keyboard.write('S');
    //arrow keys are 215-218 (R,L,D,U)
  }

  if(1000 < CircuitPlayground.readCap(A4)){
    goingDown = false;
    goingUp = false;
    Serial.println("small down");
    for(int i = 0; i < 50; i++) {
      Serial.println("SD");
      Keyboard.write('S');
      //delay(debounce);
    }
   
  }

  if(1000 < CircuitPlayground.readCap(A1)){
    goingDown = false;
    goingUp = false;
    Serial.println("small up");
    for(int i = 0; i < 50; i++) {
      Serial.println("SU");
      Keyboard.write('W');
      //delay(debounce);
    }
   
  }

  if(1000 < CircuitPlayground.readCap(A3)){
    goingDown = false;
    Serial.println("switched to up");
    goingUp = true;
  }
  if (goingUp){
      //do go up input
      Serial.println("up");
      Keyboard.write('W');
  }

}


 

No comments:

Post a Comment

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