The video I chose to make a controller for is Pokemon Leaf Green, however, it can be noted that this can work with any Pokemon game on the computer. I've been a fan of Pokemon for years, and noted the Pokemon Company's attempts at making extra peripherals for Pokemon fans and their games. I've decided to emulate the Poketch into controller form for my project!
I used an empty cardboard box to house my CPE, wires, and potentiometers, and the CPE uses an accelerometer to stimulate the "A" input on a Gameboy Advance, due to the act of moving the controller being similar to giving commands to a Pokemon, then the two potentiometers are used to input the Left and Right inputs for the bottom knob, and Up and Down for the top knob. I then made the controller have the color scheme of a Pokeball to increase its familiarity and immersion due to it supposed to be a product in the Pokemon world. The only issues I ran into was my watch straps not coming in so I was unable to construct the watch portion of the controller but I was still able to assemble everything else! Besides all of that, what else could be done to improve my controller? Any changes to its inputs or design?
//Libraries#include <Adafruit_CircuitPlayground.h>#include <Adafruit_Circuit_Playground.h>#include <Keyboard.h>#include <KeyboardLayout.h>//Code by Jason Ajucum//Variables//Debounce button pressconst int debounce = 100;//Thresholdconst int threshold = 500;int moveVert = 0;int moveHor = 0;int moveVertical = 0;int moveHorizontal = 0;boolean pressed = false;boolean watch = false;void setup() {// put your setup code here, to run once:CircuitPlayground.begin();//turn controller on and offpinMode(CPLAY_SLIDESWITCHPIN, INPUT_PULLUP);Keyboard.begin();Serial.begin(4000);}void loop() {// put your main code here, to run repeatedly://Accelerometerfloat x = CircuitPlayground.motionX();int r = map (x, -10,10, 0, 255);//PotentiometermoveVert = analogRead(A2);moveHor = analogRead(A3);moveVertical = map(moveVert, 0, 1023, 0, 10);moveHorizontal = map(moveHor, 0, 1023, 0, 10);//P1, turn left, neutral, and rightif(moveHorizontal == 10){Keyboard.press(KEY_LEFT_ARROW);delay(100);}//change &&pressed if failsif(moveHorizontal != 0 && moveHorizontal !=10){Keyboard.releaseAll();}if(!pressed && moveHorizontal ==0){Keyboard.press(KEY_RIGHT_ARROW);delay(100);}//Pitou(P2), turn up, neutral, and turn down//Come back to this laterif(moveVertical ==0){pressed = true;Keyboard.press(KEY_UP_ARROW);delay(100);}if(moveVertical !=0 && moveVertical !=10){pressed = false;Keyboard.releaseAll();}if(moveVertical ==10){pressed = true;Keyboard.press(KEY_DOWN_ARROW);delay(100);}//Poketch function/A functionif(!watch &&r>=35){watch = true;Keyboard.press('X');delay(400);}if(r <= 35 &&watch == true){watch = false;Keyboard.release('X');delay(400);}}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.