18 April 2022

Game Controller Final Project

 Sonic Blue Ring Controller


My final project is crafted by using a Blue Pool Noodles with the CPE in front. The objective is to use it as one of those kart based controllers although it's simple in design it should get the job done I hope. The design is based on a Blue Ring or in this case pool noodle because I wanted to make it connected to Sonic in a way. Sonic a fast Blue Hedgehog and he collects ring so why not for the design to combine both and see where it lands and I think it works well for this project design wise. The input and output mapping so design wise I tried to make it so you can feel the button to jump which is map on the CPE to the A button and to pause you press the B button but for everything else I planned to input it by tilting the Blue Ring left and right to make basic moves and the idea is to rotate left and right and then pressing the A button to get places. Although it's not perfect but it does work but there's errors to it that I couldn't figure out but I think it would relate to the game at hand and the output would be Sonic gathering the input on each tilt you do. Signifiers would be the Blue Ring and the feedback would be seeing Sonic move originally I wanted to have a pixel light ring to tell you when you made the input but I couldn't figure it out so at best it would just respond to the movements. At the end of it all hopefully it should functions as it should as the video down below will demonstrate although not perfect hopefully it function and act like a nice controller.  

My one question would be if there's anything I can work on to improve on this whenever the coding or the design do you think it would be more like a interesting choice for a controller? Would it been beneficial to add in lights or sounds since I opted out of that.



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



float X, Y;
const int debounce = 150;
const int threshold = 500;




//Enter Key(B Button)= Pause/Start= B Buttton
//Left Arrow(21= Left Tilt
//Right Arrow= Right Tilt
//Up Arrow= Looking Up or moving up
//Down Arrow= Looking Down or Hiding Down aka flicking down
//Jump is S or Up Tilt or A button

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

void loop() {

  float x = CircuitPlayground.motionX();
  float y = CircuitPlayground.motionY();
  
 
 if(digitalRead(CPLAY_LEFTBUTTON)) {
  Keyboard.write('S');
  delay(debounce);
 }

if(digitalRead(CPLAY_RIGHTBUTTON)) {
  Keyboard.write(10);
  delay(debounce);
}
//left tilt
if(x < 7.5) {
  Keyboard.press(216);
  Keyboard.release(218);
  delay(debounce);

  //Moving Up
}if(y < 9.5 ) {
  Keyboard.press(218);
  Keyboard.release(217);
  delay(debounce);
}
//Tilt Right or Moving Right

if(x < -7.5) {
  
  Keyboard.press(215);
  Keyboard.release(216);
  delay(debounce);
}
Moving Down or tilting Down
if(y < -9.5) {
  Keyboard.press(217);
  Keyboard.release(215);
  delay(debounce);
}


Serial.print("\t");
Serial.println(Keyboard.press(217));
Serial.print("X: ");
Serial.print(X);
Serial.print("  Y: ");
Serial.print(Y);

}




https://youtu.be/nHgwRecqVzQ




No comments:

Post a Comment

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