loading

The game Nine-Shine-Line is a simple yet entertaining LED timing game that requires the player to stop a moving light on the middle LED. As the game progresses, the speed of the lights will increase throughout ten fun-filled levels. If at any point the light is stopped at an LED that isn't the middle one, the game will reset back to the first level. Once the exhilarating tenth level is passed, all of the LEDs will light up to signify your magnificent timing abilities. Note: This game was created as a Cal Poly, San Luis Obispo, CPE 133 final project by Zack Eldredge and Mark Brown.

Step 1: Required Materials

In order to re-create this grand game, you will need the following:

  1. Digilent Nexys 3, FPGA board
  2. Xilinx ISE Design Suite software
  3. USB-to-Micro cable
  4. Eight LEDs (any color would work)
  5. Big Dome Pushbutton
  6. Wooden board
  7. Rubber feet (to go underneath the board to offset the button)
  8. Soldering iron and solder
  9. Eight resistors (100Ω were used for our red LEDs)
  10. Heat shrink
  11. Drill
  12. Drill bit
  13. Hole saw
  14. Hot glue gun
  15. Insulated electrical wire

Step 2: VHDL Modules

LED Finite State Machine (led_fsm.vhd)

This module is used to control the LEDs. In its default state, while its enable input is high, this module simply shifts the current illuminated LED to the right one space on the rising edge of the clock input (var_clk_div.vhd below). If the enable input is low, the LEDs will hold their current state. When the end is reached, the LEDs "wrap around" back to the beginning. After the final level is passed, when the win signal is high, all LEDs will be illuminated. If at any time reset is high, including in the win state, the LEDs will reset back to their default state.

Level Finite State Machine(level_fsm.vhd)

This module stores a four-bit binary value that represents the current level. The output of this module is displayed on the seven-segment display on the Nexys 3. The output is also used to determine the speed of the moving light. To change the value of the level, a pulse must be sent on the enable signal causing the level to increment by "0001". If at any time the reset signal is high, the value of level is reset to "0000".

Seven-Segment Decoder (sseg_dec.vhd)

This module is the work of Cal Poly professor, Bryan Mealy. It takes in an eight-bit binary input and displays the corresponding decimal value on the Nexys 3 seven-segment display. It's used to display the output of level_fsm.vhd.

Variable Clock Divider (var_clk_div.vhd)

This module is based off a module provided by Cal Poly professor, Bryan Mealy. This module takes the current level (from level_fsm.vhd) as an input and outputs a corresponding clock signal. The frequency of this clock increases along with the level to make the game more difficult.

LED Game (led_game.vhd)

Here we go! The main module of the game! This module primary purpose is to connect all of the above modules and to provide the intermediate logic in order to play the game. This module sends different signals to the relevant modules when the stop button is pushed. It also handles the waiting state after the stop button is pushed. This wait state pauses the game for two seconds before the next, faster, and exhilarating, level begins. This wait state also ignores additional stop button pushes to avoid debouncing issues. A block diagram showing the connections between component modules is attached (LED Game Block Diagram).

Step 3: Creating the External Game Board

While the game is perfectly playable using the LEDs and buttons on the Nexys 3 board itself (using only 7 LEDs in all of the modules), creating an external game board will make the game much more enjoyable and presentable (we used 9 LEDs). There will be a lot of freedom when creating this external board; all it needs to do is display the moving light with some LEDs and have a push button to interact with the game. As an example, we'll walk through creating the board that we designed to play our game.

Step 4: The Push Button

The centerpiece of our external board was a large red dome push button from SparkFun. This was a good starting point for the game because it is much more fun to push than the on-board Nexys 3 buttons. Plus, it has the added bonus of containing an internal LED.

The internal LED is designed to be used with a 12V DC power supply so it must be modified to be used with the 3.3V output from the Nexys 3. To do this, untwist the bottom of the button and pull out the LED-switch compartment. You should be able to pull out the plastic holder that contains the LED and a resistor. Simply desolder the included resistor and replace it with an appropriate new resistor. We used a 100 ohm resistor as the replacement.

Step 5: Creating the Surface of the Board

The idea here is to create a surface to hold the button and LEDs that is raised enough to offset the bottom of the button. We decided to use a wooden board but other materials could also work.

Keep in mind that if you're planning on spray painting the board to make it even more awesome, you'll want to do all of your drilling first.

You'll want to sketch out where you plan to place the LEDs and button before you start drilling. Keep in mind that you can use as many or little LEDs as you wish and just adjust the VHDL modules to your liking.

After planning out the placement of everything, you'll want to start drilling the holes for the LEDs. Use a drill bit that is large enough for the LEDs to fit in the hole, then secure them with hot glue.

To create the hole for the button, choose a hole saw that is large enough for the black part on the bottom of the button to fit through but small enough so that you're able to tighten the white portion of the button on the other side without it sliding into the hole. If you do not have an appropriately sized hole saw, you should be able to create a larger hole and attach the button with glue or something similar.

Finally we'll want to raise the board such that the bottom of the button isn't touching the ground. The easiest way that we found to do this was with rubber feet screwed onto the bottom. You'll want the board to be raised approximately 1.5 inches so you might need to combine two sets of rubber feet like we did.

Step 6: The Underside of the Board

Now we need to wire up the LEDs and button so that they can be connected to the I/O pins of the Nexys 3 board.

First we soldered a resistor to the anode of each of the LEDs. For our red LEDs we found that 100 ohms was an appropriate value. Next you'll want to solder additional insulated wire to the ends of each resistor; around a foot each should be enough. We also used heat shrink to cover the exposed wire and resistors.

A common ground wire needs to be soldered across all of the cathodes of the LEDs. Just cut around 6 inches of bare wire and wrap each cathode around the bare wire, soldering them together as you move across. At the last LED on each side you need to solder additional insulated wire such that it can be connected to the GND pins on the Nexys 3 board.

To connect the button, you need to solder additional insulated wire to both terminals of the LED in the button. Additionally, you will also need to connect wires to the terminals of the switch in the same fashion.

Step 7: Instructions for Playing and UCF File

While you're greatly encouraged to add your own personal touch to the game (such as more/different colored LEDs, or in a different design than a line), we'd like to provide our instructions and user-constraints file for you. The instructions are below and the .ucf file is attached. Additionally, you're welcome to hookup the led game board to the Nexys 3 in anyway you like that works. Our attached .ucf file is simply the way that we chose to map and hookup our game.

Thanks for reading about our game. We hope you enjoy making yours!

How To Play:

1. To start a new game press the right-most button on the Nexys 3 board (Reset Button)

2. The LEDs should be moving across the external board.

3. The objective of the game is to stop the moving LEDs on the middle, red, Big Dome Pushbutton.

4. To stop the moving light, press down on the Big Dome Pushbutton.

5. If you stopped the light in the middle, your score (displayed on the Nexys 3 seven-segment display) will increase.

6. The speed of the moving LEDs will increase with each successive level.

7. If, at any time, the light is stopped on an LED that isn’t the middle/button one, the game will reset and your score will go back to zero.

8. If you successfully complete all ten levels in a row, all LEDs will light up to indicate winning the game.

9. After beating the game, or if you’d like to start over at any point, simply press the right-most button (Reset Button) to start over.

<p>Great work guys! It would have been nice to get the high-level block view of your VHDL-e.g. how everything fits together and why you need each piece. Overall though, very cool design.</p>
<p>That looks like such fun! And a great project, nice job!</p>

About This Instructable

916views

7favorites

License:

More by Zack Eldredge:Nine-Shine-Line: The LED Timing Game 
Add instructable to: