My controller was meant to emulate a shoe that Sonic would wear in the video game and control him using logic that would be attributed to it. The mappings are the accelerometer tilt and proximity sensor lifting to get the feedback of running left and right as well as jumping. The signifiers rely heavily on knowing that lifting the shoe towards the front will move him in the default forward direction and that lifting up would make sense to the user for an input to jump. The design affords an inconspicuous look in theory but with the parts being so hard to fit into a small shoe it can get out of hand as seen in the picture of the final design. My big question is if it would be better to use a bigger shoe or some other method to hide the wiring inside the controller?
#include <Keyboard.h>#include <Adafruit_CircuitPlayground.h>#include <Adafruit_Circuit_Playground.h>int trigPin=A3; // proximity sensor output obtained at this pinint echoPin=A1;int a=0; //just a variable to check the current value of sensePinconst int debounce = 100;bool flag = true;void setup() {// put your setup code here, to run once:pinMode(CPLAY_SLIDESWITCHPIN, INPUT_PULLUP); // Switch as to turn onpinMode(trigPin, OUTPUT);pinMode(echoPin, INPUT);Serial.begin(9600); // For debugKeyboard.begin();delay(1000); // delay 1 secondCircuitPlayground.begin(); // Initialize CPE// define gyroscope and proximity sensor}void loop() {// put your main code here, to run repeatedly:if(digitalRead(CPLAY_SLIDESWITCHPIN)){long duration, distance;digitalWrite(trigPin, LOW);delayMicroseconds(2);digitalWrite(trigPin, HIGH);delayMicroseconds(10);digitalWrite(trigPin, LOW);duration = pulseIn(echoPin, HIGH);distance = (duration * .0343) /2;float y = CircuitPlayground.motionY(); // Y motionif(y >= 6){ // include if statement for gyroscope detecting right movementKeyboard.press(215); //moves rightdelay(debounce);} else {Keyboard.release(215);}if(y <= -6){ // include if statement for gyroscope detecting left movementKeyboard.press(216); //moves leftdelay(debounce);} else {Keyboard.release(216);}if(distance > 5 && distance < 7 && flag == true) {Keyboard.press('s');Keyboard.release('s');//do soemthing oncedelay(debounce);Serial.print("in range");flag = false;}if(distance >= 400 || distance <= 0) { //out of rangeflag = true;Serial.print("out of range");}}}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.