The general design of this controller was made to call into reference the favorite foods of the main character of the game, Miku Hatsune. Based off a Leek, a type of onion, this controller was made to play Project Diva. This rhythm game is played by pressing inputs to the beat of the song being played. It uses a color sensor at the end of the green part to translate certain colors into keyboard inputs. The idea was that instead of pressing WASD or Arrow keys to the beat of the song, you point the controller to colored tiles in front of you to the beat. Colored tiles are placed in the corresponding position to help the player understand what color leads to what input. An LED in the center also shines with the color detected to both make the controller more visually interesting and add a sense of feedback. A variable switch at the bottom is one of the inputs so that the controller can be customizable. The controller was also designed for easy assembly and disassembly, being able to split into 3 different pieces for transport. There is also a space behind the board to allow storage of cables and help avoid messes or tangles.
Inputs and Outputs:
TCS3200 (Color Sensor):
RED (A)
Green (W)
Blue (D)
B10K Potentiometer (S)
3_Clr(RGB Module):
Corresponds with the color detected and projects that color.
The circuit are all connected with the Arduino Leonardo which allows us to emulate keyboard functions.
What do you think about the overall look of the controller?
How do you think about the colored based and visual feedback response affect the player engagement for the game?
#include <Keyboard.h> //Keyboard Emulation// Color pins#define RedLED 9#define GreenLED 10#define BlueLED 11#define S0 4 //Frequency Scaling#define S1 5#define S2 6 // Pin 567 are for color filter#define S3 7#define sensorOut 8// Potentiometer pin (using 3.3v)#define POT_PIN A0int potThreshold = 450;// Calibration values for Black and Whiteint redMin = 130; // White R-130 G-110 B-80 (MIN)int redMax = 955; // Black R-955 G-845 B-610 (MAX)int greenMin = 110;int greenMax = 845;int blueMin = 80;int blueMax = 610;// Pulse Width variables (TCS3200)int redPW = 0;int greenPW = 0;int bluePW = 0;// RGB values (0-255 scale)int redValue;int greenValue;int blueValue;void setup() {// Color sensor pinpinMode(S0, OUTPUT);pinMode(S1, OUTPUT);pinMode(S2, OUTPUT);pinMode(S3, OUTPUT);pinMode(sensorOut, INPUT); // Frequency// LED pinpinMode(RedLED, OUTPUT);pinMode(GreenLED, OUTPUT);pinMode(BlueLED, OUTPUT);// Sensor scalingdigitalWrite(S0, HIGH); // Set to 100%digitalWrite(S1, LOW);Serial.begin(9600);Keyboard.begin(); // Starts keyboard emulation}void loop() {// Read redredPW = getRedPW(); // Gets the color that is put infront of the TCS3200redValue = map(redPW, redMin, redMax, 255, 0);delay(100);// Read greengreenPW = getGreenPW();greenValue = map(greenPW, greenMin, greenMax, 255, 0);delay(100);// Read bluebluePW = getBluePW();blueValue = map(bluePW, blueMin, blueMax, 255, 0);delay(100);// COLOR LOGIC //// Red (A)if (redValue > greenValue && redValue > blueValue && redValue > 140) {Serial.println("RED (A)");digitalWrite(RedLED, HIGH); // Outputs Color ReddigitalWrite(GreenLED, LOW);digitalWrite(BlueLED, LOW);Keyboard.press('a'); // Outputs keypress (A)delay(100);Keyboard.release('a');}// Green (W)else if (greenValue > redValue && greenValue > blueValue && greenValue > 140) {Serial.println("Green (W)");digitalWrite(RedLED, LOW);digitalWrite(GreenLED, HIGH); // Outputs Color GreendigitalWrite(BlueLED, LOW);Keyboard.press('w'); // Outputs keypress (W)delay(100);Keyboard.release('w');}// Blue (D)else if (blueValue > redValue && blueValue > greenValue && blueValue > 140) {Serial.println("Blue (D)");digitalWrite(RedLED, LOW);digitalWrite(GreenLED, LOW);digitalWrite(BlueLED, HIGH); // Outputs Color BlueKeyboard.press('d'); // Outputs keypress (D)delay(100);Keyboard.release('d');}// No colors shownelse {Serial.println("No Color Detected");digitalWrite(RedLED, LOW);digitalWrite(GreenLED, LOW);digitalWrite(BlueLED, LOW);}// B10K POTENTIOMETER //int potValue = analogRead(POT_PIN); // Reads Potentiometerif (potValue > potThreshold) {Serial.println("Potentiometer is alive (S)");Keyboard.press('s'); // Outputs keypress (S)delay(100);Keyboard.release('s');}// Debugging OutputSerial.print("Red = ");Serial.print(redValue);Serial.print(" | Green = ");Serial.print(greenValue);Serial.print(" | Blue = ");Serial.print(blueValue);Serial.print(" | Pot = ");Serial.println(potValue);}// TCS3200 FUNCTIONS //// Returns pulse for Red lightint getRedPW() {digitalWrite(S2, LOW);digitalWrite(S3, LOW);return pulseIn(sensorOut, LOW);}// Returns pulse for Green lightint getGreenPW() {digitalWrite(S2, HIGH);digitalWrite(S3, HIGH);return pulseIn(sensorOut, LOW);}// Returns pulse for Blue lightint getBluePW() {digitalWrite(S2, LOW);digitalWrite(S3, HIGH);return pulseIn(sensorOut, LOW);}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.