Red Light Green Light

Intro

For my "Blink" project I created a two player game interface resembling the popular child game Red-light Green-light. My goal was to create the exact same experience as a hardcore Red-light Green-light game. I want the players to have a constant rush of adrenaline that accelerates the longer they hold down the button. Each milli-second the player holds down the button is a gamble as the Red-light is near impossible to react to. Despite a few hiccups in the process, my project turned out exactly how I envisioned it. Below is a five-minute showcase of the beast in action, it takes no prisoners:
 
 

How it works

The breadboard is equipped with a green and red LED, two buttons, and a switch. Each LED is aligned with a corresponding button representing each player, a red player and a green player. While idle, the LEDs will constantly flash to show that it is on and ready to be used. Once the switch is flipped on, the red light will flash three times to countdown the start of the game. The green light will then turn on and the game begins. Each player must hold down their button to "move forward" while the light is green. However, if a player is still holding down the button when the red light turns on, the will instantly lose. The goal of the game is to "reach the finish line" while abiding by the law of the lights. 

Breadboard Setup for Red-light Green-light
The LEDs will convey information to the players through different variations of flashes. The idle flashing is slow and regular to represent a blank state. The red light will flash rapidly for a burst of time when a player loses. Conversely, the green light will flash rapidly when a player wins. After someone wins or loses, the player(s) who won will have their light lit up until the game switch is turned off. After turning the game off, each LED will flash a number of times in accordance to the number of times each player has won. In addition, these LEDs will be flashing simultaneously in order for the players to easily determine the difference in wins. After this, the game will go back to its idle flashing state until the game switch is flipped on once again. Each player's win count will persist until the Arduino is reset. 

Road-blocks & What I learned

The main roadblock I encountered was uncovering how to properly wire the buttons to the Arduino in the way I needed for ease of use. Unlike the sleek switch, the bulky buttons take up an entire 3 x 4 set of pins when not placed over the divide. This leaves only one open pin on each side of the button. As a properly wired button requires 3 pins in total, 2 of which must be on the same side, this would not work out. After doing some quick research on how breadboards function, I realized that the obvious solution was to simply connect one pin into a separate row via wire. There I connected my input and pull down resistor and the button worked flawlessly. 

After I was able to successfully set up all of my required inputs and outputs, the coding process began. As I am already quite well versed in programming, I did not really run into any major issues. I just simply looked at the Arduino IDE documentation whenever I was unsure of how to implement something. The only aspect I was unsure of was how to utilize functions. While I believe I understand it now that I have finished the project, the documentation was not adequate enough for me to comfortably implement functions within my time constraint.

In the end, I gained a solid foundation in both the wiring and programming of my Arduino.


Circuit Schematic


Links:

Comments

Popular posts from this blog

Punch Buddy

Anime Opening Quiz