Concept Description
For my final project for this class, I have created Twisted Twister, a version of the popular game twister, that is played with fingers! The challenge is simple – a wheel spins, gives you a color and a hand(left or right) and you press that button with a finger of the respective hand. Every right press gives you a point and every wrong press instantly ends the game. If you manage to have all your fingers successfully on the board, you win!!
Implementation
P5.js : Most of my game is heavily reliant on the p5.js side since I use it to control the entire game logic and display. In the game I have a wheel that spins based on speech recognition. For this I’ve used the p5.speech library that does speech recognition using API functionality. The wheel in itself, is an array of equal divisions of 4 colors. While the wheel is static, there is a black spinner, that’s the one that moves and stops on a particular section and the center of the wheel displays the color. The hand the user has to use is also mentioned on the top with the same color with the intent of making it easier for the user without getting confused with so many bright colors on the screen.
Once the user presses the required switch, they have to continue holding it. I have created an array to track the switches which are already pressed and I compare it with the array of switch states I obtain from the arduino to compare the switch states at various points in the game. If a switch is correct and wasn’t already pressed, the score adds and for a wrong switch the game ends.
Arduino: From the arduino side, it is pretty simple. I have 12 switches, 3 of each of the 4 colors, whose states I obtain in the form of a string but then use it in p5js in the form of an array.
const int redSwitch1 = 13; const int redSwitch2 = 12; const int redSwitch3 = A0; const int blueSwitch1 = 11; const int blueSwitch2 = 10; const int blueSwitch3 = A1; const int greenSwitch1 = 9; const int greenSwitch2 = 8; const int greenSwitch3 = A2; const int yellowSwitch1 = 7; const int yellowSwitch2 = 6; const int yellowSwitch3 = A3; void setup() { Serial.begin(9600); pinMode(redSwitch1, INPUT_PULLUP); pinMode(redSwitch2, INPUT_PULLUP); pinMode(redSwitch3, INPUT_PULLUP); pinMode(blueSwitch1, INPUT_PULLUP); pinMode(blueSwitch2, INPUT_PULLUP); pinMode(blueSwitch3, INPUT_PULLUP); pinMode(greenSwitch1, INPUT_PULLUP); pinMode(greenSwitch2, INPUT_PULLUP); pinMode(greenSwitch3, INPUT_PULLUP); pinMode(yellowSwitch1, INPUT_PULLUP); pinMode(yellowSwitch2, INPUT_PULLUP); pinMode(yellowSwitch3, INPUT_PULLUP); } void loop() { // creating a comma-separated string to represent the states of all switches String switchStates = String(digitalRead(redSwitch1)) + "," + String(digitalRead(redSwitch2)) + "," + String(digitalRead(blueSwitch1)) + "," + String(digitalRead(blueSwitch2)) + "," + String(digitalRead(greenSwitch1)) + "," + String(digitalRead(greenSwitch2)) + "," + String(digitalRead(yellowSwitch1)) + "," + String(digitalRead(yellowSwitch2)) + "," + String(digitalRead(redSwitch3)) + "," + String(digitalRead(blueSwitch3)) + "," + String(digitalRead(greenSwitch3)) + "," + String(digitalRead(yellowSwitch3)); // sending the string data to p5.js Serial.println(switchStates); delay(500); }
Interaction design: In terms of interaction design, constructing the physical aspects and combining p5js and arduino, it was somewhat frustrating because of the amount of errors but also my favorite part of the project (specifically soldering!! I found myself in the lab soldering my million wires at 8am in the morning and it was therapeutic!!).
I have chosen to place the 12 switches in diagonal rows onto an acrylic board. Since I had multiple wires, I decided to make a box so the wires can go inside without causing a visual mess. The laser cutting took a lot of time but eventually worked out (super grateful to all the lab assistants for helping me). I wanted to use switches bigger than the ones in our kit and couldn’t find as many with different colors, I put circle stickers beside these buttons indicating what color they belong to. Assembling and serial communication was easy. The only part of the interaction that took me the most time was the speech recognition. While the code worked perfectly sometimes, it would randomly get disconnected in the middle and it was difficult to come up with an alternative way to control spinning the wheel without speech recognition and hands.
Aspects that I’m proud of
One of my biggest challenges was coming up with an idea for this project. Either the idea was too vague or too ambitious. Once I decided on this game I had constant doubts of whether or not it would be fun but after the laughs during the user testing, I think it would pass off as good enough for a first timer.
In terms of code, I’m really happy with the speech recognition and while I did get a reference for how to make the wheel spin, I had to break the code down and modify it a lot to make it work with my game logic and I’m really happy it worked out finally!! I found a fix for the speech recognition disconnection and now it works almost all the time! I found it relaxing to keep stretching my fingers for playing this game as they’d become stiff from hours of typing!!
Future improvements
I would want to try to blackout the sections of the wheels that are already visited so the user wouldn’t have to pass it manually if the same color appears and there’s no switch of that color left. I want to make my circuit and code more organized that what I currently have. I could also consider adding a microphone closer to the user to make the speech recognition more efficient. Overall I’m really happy with the way it turned out but would love to make this more fun and engaging with more time in hand.
References
Speech Recognition: https://github.com/shiffman/A2Z-F18
Spinning wheel: p5.js Web Editor | Spinning Wheel