Group 7: Skull Shock
Skull Shock
Do you have cat-like reflexes? Are you secretly a ninja? If you answered yes to either of these, then hedge your bets against ‘Skull Shock‘ , the game which puts your reaction time to the test!
‘Skull Shock‘ is an interactive game which tests your reaction time based on your sense of touch. Once a buzz is felt, then wack away on the buttons to lock in your reaction time. If you’re reactions are Miyagi-esque, then the next round will be ready for you, but if you fail…then you will be thrown into the Hall of Failures along with the Green Lantern Movie and the 2014 England World Cup Squad.
Do you have what it takes to go toe-to-toe with ‘Skull Shock‘ ?
Planning
In order to ensure a successful outcome is achieved, the project must be planned in advance. This will involve allocating roles to each individual member, producing an Action Plan and also making a Gantt Chart to organise the structure of the whole project.
Assignment of Roles:
Wisdom Ejuetami
- Coding
- Final Product Design and Making
- Sourcing Materials
Ruby Edwards
- Coding
- Breadboard Construction
- Sourcing Materials
Thomas Childs
- Coding
- Blog Design and Formatting
Action Plan:
Gantt Chart:
Research
Existing Products:
MOART Reaction Time Panel With PsymCon Control (1):
- This Reaction Time Panel is a reaction time measuring device that employs the Multi-Operational Apparatus for Reaction Time system (MOART).
- Tasks such as Go/No Go tasks for the study of higher centers of the brain, and more complex discriminate reaction time tasks to study cognitive processing can be used on this device.
- The system tests hand reflexes, shown by the finger holes which output a stimuli to test the user.
- Although useful, this product is quite expensive, retailing at £4,828.99.
- The design is also very simplistic, only basic shapes and symbols are used.
- It also tests a range of reaction based skills, whereas our design should focus on one method (e.g. picking one random area on a slate to click or touch).
Bop It! (2):
- Bop It! is an interactive children’s reaction game that tests the users reactions through asking them to push, twist and pull certain areas of the device.
- Aimed at children 8 and over, the product contains a smooth outer shell that is child safe and would not result in any injuries or safety issues based on the design. Bright colours are also used to separate each section to make it easier for the child to distinguish between areas.
- Retailing at £19.99, the product is affordable for families, meaning the device is well known and sold through leading retailers.
- Bright colours and a smooth outer shell can be implemented in our design to make it appeal to the audience more.
Components:
- Vibration Motor – This can be used to output a vibration in a random area to test reaction speed.
- LED Lights – This can be used to display to the user the number of lives they have left. It can also be used in the prototyping phase acting as the vibration motor until the parts are ordered.
- Piezo Element – This can be used to notify the user of a correct/incorrect input on the device, outputting different tones based on success of the guess. It can also be used to signify the start and end of each game.
- Pushbutton – This can be used as an input device to lock in the users guess.
Game Concept
Before coding can begin for the project, the concept must be established through a flowchart and defining key areas of the design.
Flowchart:
Key Areas Required for the Design:
- Breadboard and Arduino should be hidden/integrated into the design.
- Features such as LEDs and Pushbuttons should be clearly visible to the user.
- Piezo Element should be positioned in a manner that ensures the user can clearly hear the sounds and that it is not muffled.
- Bright colours can be used to make the design appeal more to children.
- Bluetooth or wire extensions can be used to break up the game into different pieces, meaning multiple breadboards would be needed.
- Above all, the application should feel like a game to appeal to a variety of users.
Production
For each iteration of the code, a video was taken to show what the Arduino board would do. This can be seen below in the recap of each week. A general overview of what was planned out and achieved throughout each week is also included.
Week 1:
For our introductory meeting, the group firstly decided on a brief (Project 3). This was decided fairly quickly as we all selected our own top three choices for the project, and project 3 appeared in either the top or second most preferred choice for the project. We then moved onto producing a plan of action in order to complete every aspect of the project in the allocated time. This plan allocated each member their own job for the following weeks, playing to each of our strengths.
By the end of the week, brainstorming had been completed, allowing us to decide on the path to take with this project beginning in Week 2. The brainstorming page can be seen below.
Week 2:
Starting the week, the group met and finalized on a design, which is a Skull/Hat reaction game. This works on the principle that the user will wear a hat containing vibration motors that will randomly vibrate. The user will then have to click the button on a model skull that corresponds to the position of the active vibration motor within the hat. If the user takes too long to guess or gets it wrong, they will lose a life.
Once we had the game concept finalised, we produced a components list and ordered the required parts from the Electronics Lab.
For the first code iteration, the group was able to get the four buttons on the breadboard to register and output their position number. We were also able to add a starting light and sound sequence that plays at the beginning of the game. The videos showing these features in action can be seen below.
The aim now for week two is to set a random LED to light up, checking if the users guess is correct and also printing the time it took between a buzz and the user clicking the right button.
Starting Light and Sound Sequence
Getting Buttons to Register to the Serial Monitor
Week 3:
At the beginning of week 3, we collected the ordered materials from the electronics lab so the design could be developed further. A meeting was also arranged to review the circuits and coding of the previous week. This was also needed to combine sections of code that were produced between meetings.
This week was a success, as we were able to get the design to select and output a random LED which corresponded to the correct button. This also let the user know if their guess was successful by outputting a sound – if a higher pitch plays, the guess is correct, whereas a lower pitch means the guess is wrong.
Once this was complete, we worked on getting the serial monitor to output the time taken for the user to guess the correct button. This was achieved by starting the time as a random buzzer is selected and the recording an end time when the user clicks the button. The reaction time is therefore the difference between the two values. Videos showing these can be seen below.
The aim now for week 4 is to separate the number of hits into levels, change the wait time based on the level that they are on and also introduce a lives system. In addition, we will swap out the LEDs for vibration motors as they have now arrived.
Result of the User Guess
Result of User Guess and Reaction Time
Week 4:
In the penultimate week, we were able to complete the coding and functionality of the design. This involved producing levels to the design while also increasing the difficulty with each passing level, as well as showing the user that they have lost a life if they guess incorrectly.
Also, the design was altered from using vibration motors inside a wearable hat to placing them on the skull itself and having an external pushbutton board. This design alteration was due to the availability of parts, as having long wires come out of the hat would make it difficult to wear. Using an external board for the pushbuttons, rather than having them directly on the Arduino board, allows them to be positioned so that they reflect the pattern of the buzzers, making the game more intuitive for the user. In the future, the hat design could be used but with a Bluetooth adapter that connects the vibration motors to the breadboard rather than using long wires.
This meant that the design just needed to be refined in terms of composition and look for the final piece. The final design involves attaching the vibration motors to the model skull and the buttons to a separate setup, with everything connected to one Arduino board.
Concept Sketch of Final Design for Prototype
A case for the external button board was designed and produced using AutoCAD 2018 and the Laser Cutter. The design was successfully cut from an Acrylic sheet and assembled securely using Tensol Glue.
The design was also altered so that the user only loses a life if they guess wrong. This is due to coding and timing issues.
A video of the final functionality features of the design can be seen below.
Therefore, all that is left is to produce and practice the presentation in the final week of this project.
Game Over/Losing a Life
Level System of Reducing Time between LED Trigger
Game Logic with Vibration Motors
LEDs with Lives Function
Week 5:
In the final week, the project presentation was produced and practised by the whole group.
We also ran through playing the game so that we all know exactly how to play the game in a way that demonstrates every aspect of the code functioning correctly.
Maker Manual
Overview:
‘Skull Shock’ is an interactive reaction-based game. The aim of the game is to improve the users reaction time through outputting a random vibration on a random vibration motor positioned around a model skull. When the correct button is clicked (which has a corresponding vibration motor) the user will progress onto the next level and their reaction time can be seen on the serial monitor. The game will also increase in difficulty as the game goes along, reducing the time between the user clicking a button and outputting the next vibration. But, if the user clicks on an incorrect button, they will lose a life (the user will be given 3 lives at the start of every game). When the user is out of lives, the game will finish and then restart itself.
Playing ‘Skull Shock’
Tools and Supplies:
Components & Supplies
Pushbutton (x4) – These were used as an INPUT device so that the user can lock in their guess for each level.
LED Light (x3) – These were used as an OUTPUT device to show the user how many lives they have.
Vibration Motor (x4) – These were used as an OUTPUT device to output a vibration on a random motor for the user to guess.
Piezo Element (x1) – This was used as an OUTPUT device to let the user know if their guess was successful or not, while also playing a tune when the game is finished.
Model Skull (x1) – This acted as the main theme for the design of the game while also acting as a placeholder for the vibration motors. Having this made sure the theme and idea of the game was clear, as it links nicely to the title of the game (‘Skull Shock’).
Tools
Breadboard – This was used to house the LEDs and piezo speaker. An external breadboard was also used to house the pushbuttons.
Arduino Board – This was used to run the code to the breadboard, pushbuttons and buzzers, thus allowing the game to function. It also allowed for a power source to be input to get the game to run.
AutoCAD 2018 & Laser Cutter – These were used to design and manufacture the pushbutton case so that the pushbuttons were more secure and had improved aesthetics.
Tensol Glue & Brush – This was used to glue the pushbutton case together so that the whole structure was secure and would not break easily.
Acrylic Sheet – This is the material used as the case, as it was available in blue, has a shiny finish and was lightweight. This made it desirable to make the design stand out and look more like an interactive game which would be sold on the market.
Crocodile Clips – These were used to attach the vibration motors to the Arduino digital pins while also keeping them away from the breadboard, as the original wires attached to the motors were too short to be linked to the breadboard while being stuck to the model skull.
Circuit Layout Diagram:
Shown below is the basic design of our Arduino circuit – in reality, the buttons and vibration motors are not connected directly to the breadboard. This circuit layout diagram was created using ‘fritzing’.
Project Build:
Below is the step-by-step method on how the design was built and how to set up the game to be ready to play.
(1) Assemble the components on the breadboards as shown in the diagram in the ‘Circuit Layout Diagram’ section.
(2) Design and produce an AutoCAD file to contain all the parts of the pushbutton case (as shown in the image below) and save the file as a .dxf file. Note that the cut lines should be in red to allow the Laser Cutter to understand which lines to cut.
(3) Laser Cut the .dxf file using the Laser Cutter. Ensure to turn on the extractor fan so that no harmful fumes are expelled and also do not look directly at the light coming from the laser, as it can damage eyesight.
(4) Once cut, remove the protective film from the parts and glue the design together using Tensol Glue.
(5) Peel off and stick the Vibration Motors to the correct position on the model skull.
(6) Connect the circuit to a laptop using the connection lead and then run the code to start the game.
Code:
int speakerPin = 6;
int buzzerPins[] = {2, 3, 4, 5};
int buttonPins[] = {7, 8, 9, 10};
int livesPins[] = {11, 12, 13}; //11 = left, 12 = middle, 13 = right
int sounds[] = {956, 1436, 1915};
int hitSound = 1915;
int missSound = 956;
int delayTime = 350;
int startDelay = 100;
int lastButtonState = 0;
int buttonState = 0;
int guess = 0;
int onBuzzer = 0;
int num = 4;
int noOfHits = 0;
int level = 1;
float lives = 3;
int win = 15;
String result = “MISS, try again”;
unsigned long startTime;
unsigned long endTime;
unsigned long duration;
void setup() {
Serial.begin(9600);
for (int i = 0; i < num; i++) {
pinMode(buttonPins[i], INPUT);
pinMode(buzzerPins[i], OUTPUT);
}
for (int x = 0; x < lives; x++) {
pinMode(livesPins[x], OUTPUT);
}
startNewGame();
}
void loop() {
for (int i = 0; i < num; i++) {
getGuess(i);
}
if (result.compareTo(“HIT good job!”) == 0) {
nextGo();
}
}
//run in setup() and checkGuess() – if game lost or won, it resets
void startNewGame() {
delay(1000);
result = “MISS, try again”;
noOfHits = 0;
level = 1;
lives = 3;
Serial.println(“Welcome to SKULL SHOCK”);
startLights();
for (int i = 0; i < num; i++) {
digitalWrite(buzzerPins[i], LOW);
}
for (int x = 0; x < lives; x++) {
digitalWrite(livesPins[x], HIGH);
}
Serial.println(“Click a button to guess which buzzer is activated”);
Serial.println(“”);
setRandomBuzzer();
}
//run in loop() – turns off LEDs, makes MISS default and sets new buzzer if correct
void nextGo() {
for (int i = 0; i < num; i++) {
digitalWrite(buzzerPins[i], LOW);
}
result = “MISS, try again”;
setRandomBuzzer();
}
//run in startNewGame() and nextGo() – selects random buzzer, changes wait time based on level and starts timer on first run
void setRandomBuzzer() {
onBuzzer = random(num);
if (level == 1) {
delay(random(1750, 2000));
} else if (level == 2) {
delay(random(1500, 1750));
} else if (level == 3) {
delay(random(1250, 1500));
} else if (level == 4) {
delay(random(750, 1250));
} else if (level == 5) {
delay(random(250, 750));
}
digitalWrite(buzzerPins[onBuzzer], HIGH);
startTime = millis();
}
//run in nextGo() – signifies very start of game
void startLights() {
for (int i = 0; i < lives; i++) {
digitalWrite(livesPins[i], HIGH);
tone(speakerPin, sounds[i], startDelay);
delay(startDelay);
}
for (int x = 0; x < lives; x++) {
digitalWrite(livesPins[x], LOW);
tone(speakerPin, sounds[x], startDelay);
delay(startDelay);
}
delay(delayTime);
}
//run in loop() – obtains guess index, then calls checkGuess()
void getGuess(int i) {
buttonState = digitalRead(buttonPins[i]);
if (buttonState != lastButtonState) {
if (buttonState == LOW) {
guess = buttonPins[i] – 7;
checkGuess();
delay(500);
}
}
lastButtonState = buttonState;
}
//run in getGuess() – checks whether guess index matches buzzer that is on
void checkGuess() {
result = “MISS, try again”;
for (int i = 0; i < num; i++) {
if (guess == onBuzzer) {
result = “HIT good job!”;
tone(speakerPin, hitSound, delayTime);
endTime = millis();
duration = endTime – startTime;
Serial.println(duration / 1000.0);
noOfHits++;
if (noOfHits == win) {
result = “You’ve completed the game! Hit RESET to play again”;
digitalWrite(buzzerPins[onBuzzer], LOW);
winBlink();
startNewGame();
}
break;
} else {
lives = lives – 0.25;
tone(speakerPin, missSound, 200);
}
}
Serial.println(result);
String stringOne = “Number of lives: “;
String stringThree = stringOne + lives;
Serial.println(stringThree);
checkLevel();
checkLives();
Serial.println(“”);
}
//run in checkGuess() – checks level based on number of correct guesses
void checkLevel() {
if (noOfHits == 3) {
level = 2;
Serial.println(“”);
Serial.println(“LEVEL 2”);
} else if (noOfHits == 6) {
level = 3;
Serial.println(“”);
Serial.println(“LEVEL 3”);
} else if (noOfHits == 9) {
level = 4;
Serial.println(“”);
Serial.println(“LEVEL 4”);
} else if (noOfHits == 12) {
level = 5;
Serial.println(“”);
Serial.println(“LEVEL 5”);
}
}
//run in checkGuess() – checks how many lives the user has and changes LEDs accordingly
void checkLives() {
if (lives == 2.00) {
digitalWrite(livesPins[0], LOW);
} else if (lives == 1.00) {
digitalWrite(livesPins[1], LOW);
} else if (lives == 0.00) {
digitalWrite(livesPins[2], LOW);
Serial.println(“YOU DIED. Restarting…”);
Serial.println(“”);
loseSound();
startNewGame();
}
}
//run in checkGuess() – signifies win through LED and sound outputs
void winBlink() {
for (int i = 0; i < 3; i++) {
digitalWrite(livesPins[0], HIGH);
digitalWrite(livesPins[1], HIGH);
digitalWrite(livesPins[2], HIGH);
tone(speakerPin, hitSound, delayTime);
delay(delayTime);
digitalWrite(livesPins[0], LOW);
digitalWrite(livesPins[1], LOW);
digitalWrite(livesPins[2], LOW);
delay(delayTime);
}
}
//run in checkLives() – signifies that user has no lives remaining
void loseSound() {
for (int i = 0; i < num; i++) {
digitalWrite(buzzerPins[i], LOW);
}
tone(speakerPin, 932, 1000);
delay(delayTime);
tone(speakerPin, 880, 1000);
delay(delayTime);
tone(speakerPin, 831, 1000);
delay(delayTime);
tone(speakerPin, 784, 2000);
delay(1000);
noTone(speakerPin);
}
Testing and Shortcomings:
For testing, please refer to videos from the Production section.
Overall, there were little shortcomings which effect the functionality of the final game, there were just a few alterations that would be made in regard to the design of the game if it were to be made for sale to the public. These shortcomings are listed and explained below.
- In terms of code functionality, the only issue with the game is that it does not take a life away from the user if they have taken too long to guess. This is due to issues with coding and time available, as this feature would be added in future iterations of the game.
- The main issue with the design is that the intention was to use a hat opposed to a button case, as it would have linked to the direct position on the users skull with the model skull. This was not possible as the shear quantity of wires made it messy and cluttered if it were to be inside a hat. It would also have restricted the users movement unless a Bluetooth adapter was added so that no cables were needed between the breadboard and hat. But, this was not possible to source due to the cost of the adapter.
- Also, to improve the ergonomics of the design, a stripboard could have been used to arch the buttons so that they are in line with the users fingers, opposed to being in a straight line as they currently are.
- The serial monitor could also be removed entierly in future iterations as a LCD Screen could be sourced and added to display the users reaction time instead of the serial monitor which is used in the designs current state.
References
(1) Control, M. (2018). MOART Reaction Time Panel With PsymCon Control. [online] Health and Care. Available at: https://www.healthandcare.co.uk/function-perceptual-cognitive-assessment/moart-reaction-time-panel-with-psymcon-control.html?gclid=Cj0KCQiA6JjgBRDbARIsANfu58Hz345k81ljmf8-6ZLWLpVDfsuQRPHAvt9xoWrNxnnnmkJG2ZppEE4aAhQREALw_wcB [Accessed 4 Dec. 2018].
(2) It!, B. (2018). Bop It! – Hasbro Board Games UK. [online] UK Site. Available at: https://www.smythstoys.com/uk/en-gb/hasbro-board-games/bop-it-/p/152080 [Accessed 4 Dec. 2018].