26 November 2023

Glove Box-Grabber Controller (Super Crate Box)



I created a responsive game glove that translates finger gestures into in-game actions tuning play into a physically immersive experience for the game Super Crate Box, a game where you collect boxes and avoid enemies with movement. The concept centers around a lightweight knit glove with flex sensors across the index and middle finger. As you curl a finger, the sensor reads how far it bends, then moves your on-screen character proportionally left or right. To jump, simply pinch your thumb and pointer finger together to activate a pressure trigger in the thumb socket. The form fitting fabric lets you pull off all these complex gestures combos seamlessly, way faster than trying to mash a bunch of buttons with just your thumbs. I soldered wires to each sensor that connects to the Circuit Playground Express stuffed inside the glove to track those hand motions sand to move the character left, right or jump with different height being tracked. This glove has unmatched control from all the built-in sensors, but I want to keep expanding what motions it can detect for game types without making it too tricky to master. Getting the sizing right for every hand size is tough too. Still, for now this controller shows off new ways your body can interact with games beyond what keyboards and console controllers allow. I originally wanted to develop this glove controller for the game Plants vs Zombies however, I figured out too late that the game did not support any type of new input expect for the mouse and was too buggy to run any outside controller especially my custom made one. I decided that this game was interesting being able to collect boxes and the glove worked well for it. How can I add more gestures and inputs to make the controller more unique?







Code:

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

// Flex Sensor 1
const int FLEX1_PIN1 = A1;
const int FLEX1_PIN2 = A2;

// Flex Sensor 2
const int FLEX2_PIN1 = A3;
const int FLEX2_PIN2 = A4;

// Pressure Sensor
const int PRESSURE_PIN1 = A5;
const int PRESSURE_PIN2 = A6;

void setup() {
  Serial.begin(9600); // Initialize serial communication
  CircuitPlayground.begin();
  Keyboard.begin();
}

void loop() {
  // Read Flex Sensor 1
  int flex1T1 = analogRead(FLEX1_PIN1);
  int flex1T2 = analogRead(FLEX1_PIN2);
  int flex1 = (flex1T1 + flex1T2) / 2;

  // Read Flex Sensor 2
  int flex2T1 = analogRead(FLEX2_PIN1);
  int flex2T2 = analogRead(FLEX2_PIN2);
  int flex2 = (flex2T1 + flex2T2) / 2;

  // Read Pressure Sensor
  int pressureT1 = analogRead(PRESSURE_PIN1);
  int pressureT2 = analogRead(PRESSURE_PIN2);
  int pressure = (pressureT1 + pressureT2) / 2;

  // Map flex sensor values to character movement (Left, Right arrow keys)
  int flex1Movement = map(flex1, 0, 1023, 0, 10);
  int flex2Movement = map(flex2, 0, 1023, 0, 10);

  // Print sensor values to the Serial Monitor
  Serial.print("Flex1: ");
  Serial.print(flex1);
  Serial.print(" | Flex2: ");
  Serial.print(flex2);
  Serial.print(" | Pressure: ");
  Serial.print(pressure);
  Serial.print(" | Flex1 Movement: ");
  Serial.print(flex1Movement);
  Serial.print(" | Flex2 Movement: ");
  Serial.println(flex2Movement);

  // Move character based on flex sensor values
  if (flex1Movement > 2) {
    Keyboard.press(KEY_LEFT_ARROW); // Move left for flex sensor 1
  } else {
    Keyboard.release(KEY_LEFT_ARROW); // Release left arrow key
  }

  if (flex2Movement > 2) {
    Keyboard.press(KEY_RIGHT_ARROW); // Move right for flex sensor 2
  } else {
    Keyboard.release(KEY_RIGHT_ARROW); // Release right arrow key
  }

  // Jumping using the pressure sensor
  if (pressure > 500) {
    Keyboard.press('Z'); // Press Z key
    delay(100); // Adjust this delay if needed
    Keyboard.release('Z'); // Release Z key
  }

  delay(100);
}



No comments:

Post a Comment

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