Two player snake game







A Brief Description

Required Equipments

How it works?

Block Diagram

Algorithm

Detailed Pin Diagram

Problems Faced

Video Link

Group Members Information

Course Teacher






A Brief Description


In this project we made a two player snake game in which we used dot matrix display as the board.There are two version based on controller.

In the wired version, push buttons are used to control the two snakes

There are eight push buttons for two players each having up,down,left and right buttons for controlling respective snakes.

In the wireless version, web-based remote control is introduced to control the two snakes. Any two device having wifi can connect to the game board through wifi and select snake. Then from a web interface can control respective snake. To show their scores we used two seven segment display.
There are three levels in the game. First having no obstacle, second having small obstacles and third having larger obstacles. To go to next level one of the player must score four. If any player faces the obstacles his score is decreased. In the higher levels the speed of the snake get increased. The food appears at random places at a fixed interval. After finishing the thrid level the player having more total score is shown as the winner in the display.






Required Equipments


For wired version:

For wireless version:






How it works?


In the wired version, ATmega32 microcontroller having four input/output ports is used for interfacing to various hardware peripherals. Four 8X8 dot matrix displays are multiplexed to a 16X16 display. Two ports of ATmega32 are used directly to control the 16 rows of the display using restistors . One port's four pins are used for decoders input. This is a 4 to 16 decoder. The outputs of the decoders are used to control the columns of the dot matrix display. One port is used to get inputs from eight push buttons. ATmega32 takes input from buttons and accordingly sets the ports value to control the display.USB-Asp burns the code into ATmega32.

In the wireless version, the dot matrix board and the ESP8266 wifi module are interfaced with the Arduino Mega through it's digital pins and serial pins respectively. First ESP8266 creates an access point and starts a server, where players can connect through wifi. Connecting to server player gets a web interface with control buttons. When any button is pressed, a request is received at ESP8266. Then ESP8266 gives an interrupt to Arduino-Mega and sends the player's move to Arduino-Mega. When Arduino-Mega gets interrupt, its interrupt routine reads the player's move from ESP8266 serial channel and reflects it in display. 16 digital pins of Arduino-Mega is used to control 16 columns of dot matrix display. Another 16 digital pins of Arduino-Mega is used to control 16 rows. USB-ttl is used to upload arduino firmwared code to ESP8266. Arduino Mega is programmed through it's special cable.






Block Diagram




                                                                       pin diagram

                                                                                                                                               fig.1 Block Diagram - wired version





                                                                       pin diagram

                                                                                                                                               fig.2 Block Diagram - wireless version






Algorithm




       1.Start
              2.Dot matrix is loaded with initial board configuration
              3.two 7 segment display is loaded with initial score zero
                     4.ATmega32 waits for button press
                            5.If level 3 completed
                                   6.Show winner's name and load new game.
                            7.If level 1 or level 2 completed
                                   8.Load next level.
                            9.If a player takes food
                                   10.Increase his score.
                            11.If snake hits obstacle
                                   12.Decrease that player's score.
                            13.If a button is pressed
                                   14.Move the snake in that direction.
                            15.Go to (4)
       16.End

For both wired and wireless version follows same algorithm with one dissimiliarity. In wireless version, player's inputs come in serial channel instead of from push buttons directly as like wired version.






Detailed Pin Diagram




                                                                       pin diagram

                                                                               fig.3 Pin Diagram for Dot matrix and push button with ATmega32 and decoder(7 segment display omitted)






Problems Faced


  1. The pin configuration of dot matrix was not straight forward so we faced problem to get the right pin configuration and turn the display on.

  2. Turning on the seven segment displays with a few available pin.

  3. Sometimes the response of the button was poor.

  4. We had to give power from both usb-asp and adapter as taking power from adapter was not enough.

  5. Some wires had problem which made us to work a lot to find the problem.

  6. Serial communication between ATMega and ESP8266 was troublesome. Corrupted data were received in ATMega. Using Arduino-Mega eased to solve this problem.

  7. Sudden disconnection of ESP8266 server was a big problem.

  8. Server response latency was noticable. Using a little bit advance knowledge in networking can solve this problem






Video Link



Group Members Information


Section B2: Group 1






Course Teachers


  1. Md. Abdus Sattar

  2. Md. Aashikur Rahman Azim

  3. Md. Iftekharul Islam Sakib





Back to top