Pictures of Controller
Our glove based controller is an intuitive input device for a runner based game, designed to enhance gameplay immersion through motion and touch-based controls. It utilizes a potentiometer sensor, the Circuit Playground Express (CPE)’s built-in accelerometer sensor to map real-world gestures and actions to in-game mechanics. The design leverages natural gestures for direction control, environmental feedback for jumping. These affordances ensure the controller is intuitive and easy to use while maintaining flexibility for varied gameplay scenarios. The accelerometer sensor detects wrist tilts for left and right movements.The potentiometer sensor monitors ambient light levels to trigger jumping actions in response to brightness changes. Left and right movement in the game based on wrist tilts. Jumping occurs when you rotate the potentiometer. Feedback is provided through LEDs on the CPE, which flash blue for right movement, red for left movement and green for jump detection. This integration strengthens the player’s sense of control and reinforces their actions with responsive, real-time feedback. The glove aligns with the platformer’s active and engaging theme by transforming real-world gestures into meaningful in-game actions, fostering a dynamic and immersive gaming experience. Are there specific areas where the controls could be simplified or improved for better usability?
Video of Controller
Team Contributions
Jordan Oliver: Programmed accelerometer input for left/right movement and potentiometer sensor integration for the jumping. Publishing the blog post. Recorded the video and took pictures.
Gary Hazelgren Developed LED-based feedback for player actions. Created the glove prototype and connected all hardware components. Voiceover for the video and playtester.
Jordan Oliver: Programmed accelerometer input for left/right movement and potentiometer sensor integration for the jumping. Publishing the blog post. Recorded the video and took pictures.
Gary Hazelgren Developed LED-based feedback for player actions. Created the glove prototype and connected all hardware components. Voiceover for the video and playtester.
Schematic
Code
#include <Adafruit_CircuitPlayground.h>
#include <Keyboard.h>
// Define debounce intervals (in milliseconds)
const unsigned long debounceInterval = 50;
// Variables to store the last action times for each key
unsigned long lastActionA = 0;
unsigned long lastActionD = 0;
unsigned long lastActionS = 0;
unsigned long lastActionW = 0;
// Variables to track the current state of each key
bool isPressedA = false;
bool isPressedD = false;
bool isPressedS = false;
bool isPressedW = false;
void setup() {
// Initialize the Circuit Playground Express
CircuitPlayground.begin();
// Start Keyboard
Keyboard.begin();
// Turn off all NeoPixels initially
CircuitPlayground.clearPixels();
}
void loop() {
// Read accelerometer data
float x = CircuitPlayground.motionX(); // X-axis
float y = CircuitPlayground.motionY(); // Y-axis
// Read light sensor data
int lightLevel = CircuitPlayground.lightSensor(); // Light intensity
// Get the current time
unsigned long currentTime = millis();
// Handle tilt left (A key)
if (x < -5) {
if (!isPressedA && (currentTime - lastActionA > debounceInterval)) {
Keyboard.press('A');
isPressedA = true;
lastActionA = currentTime;
CircuitPlayground.setPixelColor(5, 255, 0, 0); // Change LED to red for left movement
}
} else {
if (isPressedA && (currentTime - lastActionA > debounceInterval)) {
Keyboard.release('A');
isPressedA = false;
lastActionA = currentTime;
CircuitPlayground.clearPixels(); // Turn off LED
}
}
// Handle tilt right (D key)
if (x > 5) {
if (!isPressedD && (currentTime - lastActionD > debounceInterval)) {
Keyboard.press('D');
isPressedD = true;
lastActionD = currentTime;
CircuitPlayground.setPixelColor(8, 0, 0, 255); // Change LED to blue for right movement
}
} else {
if (isPressedD && (currentTime - lastActionD > debounceInterval)) {
Keyboard.release('D');
isPressedD = false;
lastActionD = currentTime;
CircuitPlayground.clearPixels(); // Turn off LED
}
}
// Handle tilt down (S key)
if (y < -5) {
if (!isPressedS && (currentTime - lastActionS > debounceInterval)) {
Keyboard.press('S');
isPressedS = true;
lastActionS = currentTime;
CircuitPlayground.setPixelColor(6, 255, 255, 0); // Change LED to yellow for down movement
}
} else {
if (isPressedS && (currentTime - lastActionS > debounceInterval)) {
Keyboard.release('S');
isPressedS = false;
lastActionS = currentTime;
CircuitPlayground.clearPixels(); // Turn off LED
}
}
// Handle light sensor (W key)
if (lightLevel > 50) { // Adjust threshold as needed
if (!isPressedW && (currentTime - lastActionW > debounceInterval)) {
Keyboard.press('W');
isPressedW = true;
lastActionW = currentTime;
CircuitPlayground.setPixelColor(4, 0, 255, 0); // Change LED to green for jumping
}
} else {
if (isPressedW && (currentTime - lastActionW > debounceInterval)) {
Keyboard.release('W');
isPressedW = false;
lastActionW = currentTime;
CircuitPlayground.clearPixels(); // Turn off LED
}
}
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.