19 April 2025

Final Project Team 18 Trail Biker Racing Controller

      
Team 18: Ethan Ryno and Jeremy Myers


    Our conceptual model for the controller was an electric bike handle with similar features for different actions but also add on the gyroscopic behavior for more interactivity. When using the controller in a game you can tell that the break lever is the break button in game, the throttle is gas for moving forward, now for tilting forward and back you need to tilt the controller to the left or right since it uses the accelerometer and because you mainly look at the game from a side view. For the games more specific inputs like restarting at the last checkpoint you have both inputs from the brake and throttle at the same time just because it was an easy button combination to do for a something the player would do a lot. For bailing out the player would just need to scream at the controller as the character in game scream as they bail out of their bike. Few controls the player can recognize before even playing while the others are kept simple but in relation to what would be best for the game and player convince. For our conceptual model how well do you think with the design choices we made are in facilitating engaging gameplay controller with the game? Ethan worked on Construction of the main controller and tester, Jeremy was the coder and conceptual designer.



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

const int Throttle = A3;
const int Brake = A7;

const int ThrottleThreshold = 500;  // Adjust based on input range
const int BrakeThreshold = 600;
const float TiltThreshold = 2.0;  // Adjust based on testing
const float YellThreshold = 100.0;  // Adjust based on testing
const int ResetThreshold = 1600;

void setup() {
  CircuitPlayground.begin();
  Serial.begin(9600);
  Keyboard.begin();
}

void loop() {
  //Throttle:
  int ThrottleValue = analogRead(Throttle); // Read value from analog input
  Serial.print("Throttle Value: ");
  Serial.println(ThrottleValue);

  // Throttle -> Up Arrow
  if (ThrottleValue > ThrottleThreshold) {
    Keyboard.press(KEY_UP_ARROW);
  } else {
    Keyboard.release(KEY_UP_ARROW);
  }

  //Brake:
  int BrakeValue = analogRead(Brake); // Read value from analog input
  Serial.print("Brake Value: ");
  Serial.println(BrakeValue);

  // Brake -> Down Arrow
  if (BrakeValue > BrakeThreshold) {
    Keyboard.press(KEY_DOWN_ARROW);
  } else {
    Keyboard.release(KEY_DOWN_ARROW);
  }

  //Tilt
  float Tilt = CircuitPlayground.motionX();
  Serial.print("Tilt Value: ");
  Serial.println(Tilt);

  // Tilt -> Left/Right Arrow
  if (Tilt > TiltThreshold) {
    Keyboard.press(KEY_LEFT_ARROW);
    Keyboard.release(KEY_RIGHT_ARROW);
  } else if (Tilt < -TiltThreshold) {
    Keyboard.press(KEY_RIGHT_ARROW);
    Keyboard.release(KEY_LEFT_ARROW);
  } else {
    Keyboard.release(KEY_LEFT_ARROW);
    Keyboard.release(KEY_RIGHT_ARROW);
  }

  //Yell
  float Yell = CircuitPlayground.soundSensor();
  Serial.print("Yell Value: ");
  Serial.println(Yell);

  if (Yell > YellThreshold) {
    Keyboard.press(' ');
  } else {
    Keyboard.release(' ');
  }

  //reset
    if (BrakeValue + ThrottleValue > ResetThreshold) {
    Keyboard.press(KEY_BACKSPACE);
  } else {
    Keyboard.release(KEY_BACKSPACE);
  }
  
  delay(100); // Wait for 100 milliseconds before the next reading
}




No comments:

Post a Comment

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