Introduction: Arduino Colour Reaction Game

Do you want to play a game that requires not only reaction skills but is more than just pressing a button at the right time? Then this is the game for you, In the Colour Reaction Game, a colour will flash and you must press the corresponding button in a certain amount of time until you have 5 times. All the while theres an led chaser right behind the RBG led distracting you. This project incorporates both digital and physical components. There is plenty of code along with physical components such as various leds and integrated circuits like the 555 timer.

Step 1: Materials

This list takes into account multiples and gives a cumulative cost for each component.

  1. 7 segment display ($1.99)

  2. RGB led ($2.99)

  3. Arduino Uno R3 ($25.99)

  4. Red led (8) ($1.60)

  5. Push buttons (3) ($3.99)

  6. 1kΩ Resistors (6) ($1.74)

  7. 330 Ω Resistors (2) ($0.33)

  8. Potentiometer ($1.99)

  9. Polarized Capacitor ($0.29)

  10. 555 Timer IC ($1.99)

  11. 4017 johnson decade counter ($1.00)

  12. Full sized breadboard ($7.99)

  13. Half sized breadboard ($4.99)

Total cost: $56.63

Step 2: Research

I first want to go over some of the inspiration I had in making this project. The project above is a simon says game where led's will flash up to 5 times and you then must press the right buttons in order. I took this idea and instead turned it into a reaction game where you must do it in quick succession and it's one at a time. This makes the game more reactionary based instead of memory based. I also added a seven segment display to show the score and some led's in the background to act as distractions. Instead of using three different coloured led's I instead used one rgb led saving materials and space. I used some of the code from the video, for example how the person in the video was able to determine the time since the simulation had started for the project which is something that came in very handy for my project as well.

Step 3: Base

The first step of the project is to set up the base. This includes resistors to all components and connecting them to ground and power. We also connected the buttons to their arduino pins. Notice how all wires are colour coded. The red leds will be connected to an external 555 timer system which we will worry about later. A common mistake can be putting the leds on the same column as either the buttons or RBG led. This would connect the led to those components which we don't want. Each button used a 1 kΩ resistor while the RBG led and the other leds both used a 370 Ω resistors. The RBG led is a common cathode so we only have to use one resistor. If you can't colour code your wires I recommend labeling each of the buttons at least so there is no confusion in which buttons corresponds to which colour for both you and future players.

Step 4: Seven Segment Display Wiring

While we connected the display to the power rails using 2 1 kΩ resistors, we must now painstakingly connect each of the pins to the Arduino. Each of the pins is connected to part of the display, we can control these pins to display certain numbers while our game is running to keep score. Notice how we connected 2 pins to 0 and 1 meaning that we won't be able to use the serial capabilities of the Arduino without these pins not working anymore. This is also a common cathode meaning that we don't have to use resistors for each pin. It is also active LOW, meaning that the pins will only turn on if given a low signal (ground). The reason for this is because the display is already connected to a high signal (power) through the resistors. Make sure to make the wiring as neat as possible as there are still pins remaining on the Arduino that we will be using. Make sure to remember which segment of the display the pins control as that will making coding easier later on.

Step 5: 555 Timer System

Using the 555 timer and a decade counter, we will be able to light up those led's in a pattern in which they look like they will be chasing each other. Remember this small breadboard is connected to the big breadboard power and ground rails. The decade counter has pins 1-10, we will be using 8 of them to power each of the red led's in the big breadboard. In this system the 555 timer is configured to work in astable mode meaning the output switches from high (5V) to low (0V), this output then acts as the clock for the decade counter which outputs the signal to each of the pins separately which makes the led's blink. The potentiometer will be controlling the speed of the clock which can make the led's blink faster (turning left will make it faster). The pins of the decade counter we will be connecting to each of the red led's anode (long leg), so make sure you place this breadboard closer to that part of the project and not too far away.

Step 6: RBG & Leds

The final wiring step is to connect the each of the led's into one of the decade counter pins. I personally choose pins 1-8 on the decade going left to right via the led's but you can choose any pattern you want, even any coloured led's you want. We also connect each of the RGB pins to the arduino, everything being colour coded. The RGB led is a common cathode as well meaning we get away with using one resistor. If your doing this project in real life your wiring won't be as neat especially for the led chaser but try your best, use tape if need be if you want some of the wires for the chaser to not be as spread apart as there is a lot of wiring.

Step 7: Schematic

Heres the final schematic of the circuit. Remember you don't have to follow everything and you can add your own twist whenever you want! Infact that is strongly encouraged as you will learn a lot more.

Step 8: Rules + Code

Assuming yours pins are the same as mine then this code should work. However if they are not you will have to adjust some of the variables in the code. There are few quirks I had to add to the code to make it run properly on tinkercad but I go over it in the comments of the code itself. Here is how the game works:

  1. Pressing any button will start the countdown from 3-1 where the leds start flashing.
  2. Press the corresponding button to whatever colour you see.
  3. Either a wrong answer or not answering in 1 second stops the game and resets the score
  4. 5 points and you win, the game resets after.

Tinkercad link: (the code can also be found here along with testing out the game)

https://www.tinkercad.com/things/cwbBxS4hH3v

Step 9: Video Demonstration

Here is a video going over the game along with showing what happens if you answer wrong or don't answer. Remember, you can try this out too with the link to tinkercad I added!