GROUP 5: REACTION GAME

 


PROJECT INTRODUCTION

For our project, we took on the challenge to create a reaction time game which tests a users reaction in multiple speeds. The user will be given points based on how quickly they respond to the light turning on. In the beginning, when the light instantly turns on, the user will have the max score which is kept being decreased through time. The user’s score is stored within the game and the difficulty increases. The user has to press a specific coloured button depending on the specific coloured light turns on. The user will lose their lives if they take too long or if they press the incorrect button corresponding to the LED colour.


USER MANUAL

The game is designed to be simple to play and easy to pick up. The design focuses on using visual cues, hence our manual is a labelled diagram. The accompanying video will also show how to play the game.

 capture 


 

PROJECT MEETINGS

Throughout working on the project, we had various meetings to analyse our performance and future implementation which could be included within our project.

Meeting I & Project Plan: Our first meeting consisted of writing down our ideas and concepts that could be implemented in our project. For starters, we considered how we are going to implement to measure the user’s reaction. The most common ways to measure the reaction is via a source as an output requesting an input. We considered implementing a light source which turns on and off causing the user to press a button to record their score. Our first idea was to utilise an LED matrix system which will have specific coloured LED sliding across the panel at different speeds where the user has to press the given button within the time it crosses the screen. However, later on, we decided that due to time constraints and our budget, we chose to utilise an LED strip and arcade buttons as they were within our budget and did not require the implementation of numerous libraries to be added within Arduino as well as it produces the same effect as the LED matrix. Below, are the attached sketches of both designs. We decided to go with a retro-style Nintendo Gameboy design with a small framework and small wooden body giving with arcade buttons attached at the bottom with the screen at the top containing 3 LED strips.

Then, we initiated a planned project schedule chart showing what tasks we need to complete as well when they are meant to be completed. This helps us keep track of which tasks have high priority and which can be done simultaneously.

 

This slideshow requires JavaScript.

 

Meeting II: Our second meeting we considered which parts we were going to purchase and researching how they are utilised within the Arduino Chipset. This helped us understand to which parts would be compatible with each other and how they are connected. As most of of our components could not be connected via normal cables, we were required to solder the wires to the component such as button and the LED strip. Thus, for starters, we decided to use jump wires and crocodile clips to see if the components can be powered and produce output before we solder them with an adhesive. Below I have screenshots of the given code testing if the buttons can be powered as well as the LED strip. The LED strip we used required us to include an external library called Fast LED allows for easy & efficient controlling of a wide variety of LED chipsets. By calling an instance of the library and defining which input ports they are inserted, you can make the lights turn on by using the function on each LED within the strip “FastLED.show();“.

_private_var_mobile_containers_data_application_6c5064f0-5913-4912-953a-5c961c5cb23a_tmp_66a21981-95ef-42e6-a487-a2f35e61eaa6_image

buttontest

    _private_var_mobile_containers_data_application_6c5064f0-5913-4912-953a-5c961c5cb23a_tmp_0c00a9f1-20e3-4b35-bc36-b0cdccb3a002_image

ledstriptest

 

Meeting III: In our third meeting, we considered to implement the LED strip to turn on at random intervals and the user having a scoring system to how long they take to respond to the LED turning on. At first, we had to generate a random value which will be assigned as the delay of when the LED will turn on. The delay required to have a random seed function through an analogue port so the value is always random and not a pseudo-random value which is performed by the commonly used random function. Furthermore, to assign a scoring system, we created a counter which beings to decrease when the light turns on. this is done through the implementation of a for loop as well as a few if statements declaring the state of the button. The decrementation of the score is done by 10 points until it reaches 0 at which the user will lose a life. During the time, we were also producing the casing of the components in a wooden frame and glued the sides together. The casing contained 4 holes at the front for the buttons and a panel at the front where the LED strips are stored. As well as 2 holes at each side, which will contain the start and reset buttons to help the user if the game has a glitch or an error. While working on the Arduino, our team member was soldering the arcade buttons to a wire while which will be implemented to the final design. We utilised crocodile clips for the button and LED strip for testing the code which is inserted into the breadboard and the Arduino chipset.

Testing Prototype

snapchat-817026761

snapchat-679812241__01

 

Meeting IV: During meeting 4, we completed 4 tasks which were crucial to the end project. We implemented features such as:

  • Random Colour Generator: This feature makes sure that the colour of the LED turned on when guessing is random every time to reduce the chances of the user predicting which colour will come next. This was accomplished by creating an array of colours and using the random function to get an arbitrary index for the array.
  • LifeLine: User lives were added to give the user more than one chance to play at their current stage as the more correct decisions given the quicker they have to pick the correct colour. We used an LED strip containing 3 LEDs with a red colour. The game starts with the user having 3 lives and if the answer is incorrect or they run out of time, they lose a life if they get the incorrect answer or if they run out of time. This is done via if statements causing the light to turn off one by one. Once all life LEDs are off, the game over effect appears on the screen.
  • Hardware implementation: We attached and implemented all the required hardware to the breadboard and calling an instance of each one. All the buttons and LED strips which will be included within the system to have an instance within the code and all function accordingly. These were implemented in decision making in the program. For example, if the user presses a green button while the LED colour is green, the user’s score is stored, lives do not decrement and the time the LED state is on, decrements by 5 making the game more fast-paced.

While the interface was being worked on, the case being developed upon making sure that the buttons and the Arduino board could fit inside allowing us to sand down any unnecessary parts as well as adding details by sanding the side making it more ergonomic and easier to hold. We also made a back cover which utilises screws to hold the wiring and components inside. The utilisation of screws allowed us to open it again if there were any wiring faults caused making it good for maintenance compared to using glue.

img_20191210_151859

_private_var_mobile_containers_data_application_6c5064f0-5913-4912-953a-5c961c5cb23a_tmp_625585ec-12e8-4503-a5c1-ba74dce2180f_image

   

Meeting V: In this final meeting, we added all the hardware to the casing and closed it in. At first, we stuck the LED strips to the clear panel with the lifeline at the bottom and the other LED on each edge (left, top and right). Then, we put the buttons inside making sure that the cables take as less space as possible then inserting the breadboard as well as connecting it to a battery. Then we made sure that all the wires were connected to the correct pins and made sure that all the hardware functions accordingly without and issues and screwed the back cover.

_private_var_mobile_containers_data_application_6c5064f0-5913-4912-953a-5c961c5cb23a_tmp_403abf8a-04a6-47a4-9ba1-97d6529aa302_image

img_7710

_private_var_mobile_containers_data_application_6c5064f0-5913-4912-953a-5c961c5cb23a_tmp_69293658-32f4-4e2b-949a-9c53597804da_image


Component Wiring Sketch

sketch


Arduino Code

The program contains various functions and variables which allow functionality to be implemented.

Variables & Setup: At first we imported the library which the LED strip uses which allows newer functions to be added to allow the LED strip to turn on. Then we defined which LED strip connects to which pin and also defining how many LEDs does each strip have. In these cases, other than the lives strip(LIVES_LED) contained 3 LEDS. These LED strips are then assigned to an array so colour can be added to each LED. Then, we created an array of colours which will be displayed on the LED strips which are red, green, blue and yellow which is used to get a random colour by using a random integer variable as its index value(randomColour). Next, we called the buttons using their pin and state as well as creating variables for the user’s lives, scores and how much the score will decrease by. Finally, I generated a variable to give the delay of which the LED turns off so each time the user guesses. Thus, the time it takes for the LED to turn on is unpredictable.

For the setup, we called each button to a which in it is assigned to and giving each LED an array list and stating which pin its assigned to. Furthermore, we gave some starting values to the variables and 2 functions to make sure that it turns all the LEDs off to reset the project removing any previous LED states and begin with the start screen. Finally, we called the randomSeed function to use an analogue pin to generate random values to differ on subsequent executions of a sketch as well as using Serial monitor for testing purposes.

Loop:  Next, the for loop checks if the start button is active by reading its state. When the button is pressed, it gives access to the next if statement to function as it sets the startState to true allowing the functions to work.

ledStateOn: This function makes sure that each time the LED strip turn on, they have a random colour and random delay for how long it takes for it to turn on. The colour array gets a random index value between its limits and the time delay as well. then the led strips array is cycled through assigning the colours randomly generated and is displayed after the random time delay generated.

getScore & guess: This function checks for what button the user pressed and checking if they got the correct answer which is processed by the guess function. Guess functions cycles through each button via if statements and check if the button pressed has the correct colour, then it stores their points and decreases the time the LED stays on for by 5. The score defines the time LED is turned on for. The function also checks for the user not pressing any button which causes the score to decrease until it reaches 0 which causes the user to lose their life. It also checks if the user pressed the incorrect button then it also causes the user to lose their life. If they run out of lives, then the code runs the gameOver function.

livesLost & userLives: This function cycles through the lives led strip and makes it blink when the user gets an incorrect answer. the userLives function checks for if the user has n lives, then n LEDs in the LED strip are on

ledOffState , ledStateOn & startUp:  startUp function creates a light effect to signify that the game is starting by fading the LEDs from red to green. This function is called when the start button is pressed. While ledStateOff and ledStatateOn function allow the LED states to be all ON or OFF via a loop.

gameOver: This function is used when the user runs out of lives causing the LED colours to fade from blue to green.

This slideshow requires JavaScript.


FUTURE IMPROVEMENTS

The first area of improvement that we would hope to make would be feedback to the user. Currently, the game calculates a score for how fast you react to a colour change. However, this is limited to being displayed on the serial monitor. As we opted to have the game wireless, in order to make it feel more like a product and to make it mobile and accessible, we cannot show this feedback. We would hope to connect an LCD screen to the game and have this display the times of the reaction in the form of a score and to also display a final score based on the reaction times as well as how long you lasted.

The second area of improvement would be possibly making the game have two players through having a larger sized box with two sets of buttons. Instead of focusing on lives, it would focus on scoring the two players in their reaction times and choosing a winner. Furthermore, it could be done by connecting two separate boxes together. This would allow users to play on their own and beat their own scores or to play against another user.

Another area of improvement would be to add feedback to the user via sound and light to further engage the user. For example, having sounds when a new colour appears and when the user press the button. Also by using the range of LEDs on the board together with sound to create losing life and finishing the game more intense.

In terms of the overall finish of the product, maybe painting the box in a colour such as grey would help create the feel of a handheld games console like a Gameboy. Also when the lights are not on the way the lives are displayed does not look as professional as we had hoped. We would place the LED strip underneath the backboard of the display and cut holes for the lights to improve upon this.

A final area of improvement would be to add a way to power the box through either a computer or a mains supply, in order to allow the game to not be dependent on batteries. If this was not possible, then a way to more easily change the batteries would be an improvement.

 

Leave a Reply