09 April 2022

Final Controller

 





Description: For the game I chose, I decided to use a Pacman clone that I made in Game Production called “Bite”.As expected the game only has up, down,left, and right movements.  For my controller, I wanted to make something that is simple and easy to use. I wanted to design it in such a way that someone can take one look at it, and instantly know what it is used for and how to work it. I included visual guidance to my controller including arrows that tell the player which input controls which movement. I also included the text “on/off” so the player knows which input controls the power..My 4 four inputs include 2 potentiometers and the d4 and d5 buttons on the circuit playground. One of the potentiometers control the power of the controller(rotate left for on and rotate right for off). I have another potentiometer.that controls the left and right movements.(rotate left for left movement and rotate right for right movement) Lastly for inputs I am using the d4 and d5 buttons for the up and down movements(d4 up movement and d5 down movement). As far as the feedback is concerned, the only real feedback that will be present is visual feedback by seeing how the player moves on the screen.I feel like the signifiers for the potentiometer may be more clear than that of the buttons.if someone twists the potentiometer they might expect the feedback to be left and right movement.However for the buttons it might not be so clear unless they are told what it does. For my question I would like to know, is there any way I could improve my button inputs? Maybe I could use something other than toothpicks? 


Code-



#include<Keyboard.h>

#include<Adafruit_CircuitPlayground.h>

#include<Adafruit_Circuit_Playground.h>


const int debounce = 1;//for button presses

const int threshold = 500;// for copasative touch

void setup() {

  // put your setup code here, to run once:

CircuitPlayground.begin();

pinMode(CPLAY_SLIDESWITCHPIN, INPUT_PULLUP);// switch

pinMode(CPLAY_LEFTBUTTON, INPUT_PULLDOWN);//BUTTON A

pinMode(CPLAY_RIGHTBUTTON , INPUT_PULLDOWN);//BUTTON B

Keyboard.begin();

}


void loop() {

  // put your main code here, to run repeatedly:

if(digitalRead(CPLAY_SLIDESWITCHPIN)){

  

if(digitalRead(CPLAY_LEFTBUTTON)){

  Keyboard.write(218);// upp

  delay(debounce);

  }

  if(digitalRead(CPLAY_RIGHTBUTTON)){

  Keyboard.write(217);//down

  delay(debounce);

  }

  //arrow keys have decimal values 215-218

 // if(CircuitPlayground.readCap(A3)> threshold && digitalRead(CPLAY_SLIDESWITCHPIN)){

 // Keyboard.write(' ');//write space

  //delay(debounce);

  

  // up and arrow keys control

  int pot= analogRead(A2);

  if(pot > 0 && pot < 500) {

    Keyboard.write(216);//left

  }else if (pot > 800 && pot < 10000){

    Keyboard.write(215);//right

  }

 }

Serial.print(analogRead(A2));

Serial.print(analogRead(A3));

}

Video-

https://youtu.be/nucZicAE0iw


No comments:

Post a Comment

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