LED BASED SNAKE GAME Group 14 1 NAME ROLL NO MAJOR Muhammad Shoaib Hassan 14100005 Electrical Engineering Syed Muhammad Ali 14100167 Electrical Engineering Muhammad Ali Gulzar 14100017 Computer Science Hassan Shabbir 14100026 Electrical Engineering PROJECT INTRODUCTION AND OBJECTIVES Led based snake game is primarily a hardware implementation of the classic NOKIA snake game on the Led Matrix. The execution and implementation of the game employs diverse skills learned at the class from the very first day and covers a wide spectrum of topics. The project appreciates the way in which different topics and techniques learnt in this course are put to practice, simultaneously, to perform a specific task. This project capitalizes on the fundamental concepts of combinational logic and incorporates other pertinent techniques such as, data storage, counter and clock. By the end of this project, we had successfully implemented the entire game along with pattern generation, food generation and scoring system. PROJECT HIERARCHY SNAKE GAME Snake's Movement Snake's Body Snake's Speed Regeneration LED Patterns Food Generation User Interface Fixed Initital Length Variable Speed Re-Entry From the Opposite Side At the Start of the Game Movement of food at the walls of the LED Scoring System Turn Left/Right Smooth Increment At the End of the game Score Automatically restarts at 30 pts Turn Up/Down Legal Moves Smooth Turning
Group 14 2 PROJECT SPECIFICATIONS 74LS08 74LS37 74LS28 555 74HCT374 7404 74LS85 74151 LED Matrix Resistors Switches Voltage Source Capacitor Tri State Buffer Decoders 74194 2732 74193 7447 AND Gates NAND Gates NOR Gates /Oscillator 8-Bit Edge D-Flip Flops Inverter Bit Magnitude Comparartor 1 to 8 Data Selectors/Multiplexers Common anode Food Controls +5V DC Supply Variable speed Octal Bus Transceivers 3-to-8 line decoder, and 2-to-4 line decoder Bi-Directional Shift Register EPROM 4-Bit Binary Counter BCD to Seven Segment Equipment Name IC Number No. Used LED Matrix 8x8 Bi-Colour 6 7-Segment Display Common Anode 2 EPROM's 2732 2 Quad Mux's 74157 14 1 to 8 Multiplexer 74151 8 Octal Bus Transceivers 74245 8 Bi-Direction Shift register 74194 8 4-Bit Comparators 7485 8 4-Binary Counter 74193 4 BCD to Seven Segment 7447 2 /Oscillators 555 2 8-Bit Edge D-Flip Flops 74374 2 3-8 Line Decoder 74138 2 2-4 Line Decoder 74HC139 1 AND 7408 12 NOT 7404 24 XOR 7432 8 Resistors 100/220/7000 Ω 40 Capacitors 10/5/20 µf 5
PROJECT DELIVERABLES (WHICH WERE ACCOMPLISHED) Group 14 3 By the end of this project, we had successfully implemented these features: 1. Movement of the snake on the LED Matrix. 2. Increment in its position with the help of a user control system only in the legal directions. 3. Variable speed of the movement of the snake as a functional feature. 4. Keeping track of the snake and regeneration of the snake once it leaves from the one side of matrix. 5. Led pattern generation at the start and end of game as an additional feature using multiplexing with the help of which the SNAKE letters were generated. MODULE COMPOSITION SNAKE GAME User Interface Snake's Length Snake's Speed Regeneration LED Pattren Food Snake Turning Smooth Turning Fixed Length Smooth Increment Variable Speed Counter LED Matrix At walls SR Latches Tristate Buffer n to 1 Mux D Flip Flops n to 1 Mux D Flip Flops Capacitor D Flip Flop n to 1 Mux Tri State bufer D- Latches ROM Counters 7-Seg Display WEEKLY BREAKDOWN WEEK 1: During the first week, we exercised our knowledge to go about this problem on the proteus software. We tackled the problems faced during the simulation process and tried to find their solution. Moreover, we learnt how to use a led matrix because it was a fundamental component of our project. WEEK 2: After having a fair idea about the proceedings, we had a go at the hardware implementation of our simulated circuit. Our main focus was to have a firm control over the functioning of counters, clocks, latches and flip flops. We strived to use these components with the led matrix such that we could build foundation for the later events. WEEK 3: Having our structure ready in the previous week, we went a step ahead in this week by implementing the incremental motion of the snake. Once this function was implemented, we finalized the length of the snake and will work on its movements on the led matrix. The functionality of the variable speed with which a snake moves on a led matrix also got implemented by the end of this week.
Group 14 4 WEEK 4: During this week, the additional features such as led pattern generation at the start and the end of the game were considered. We figured out a way to crack it through multiplexing and by using the effective ROM writing technique learnt in the lab, we accomplished this task. WEEK 5: Utilizing this time we winded up the project by giving it finishing touch. But we went a step ahead in the final week to implement, if time permits suggestion which we proposed according to which the snake eats the food and there is a proper scoring system to recognize this action. We successfully implemented and demonstrated all the deliverables along with bonus part on the day of demonstration. Week 1 Proteous Simlutaion Debugging Undetrstanding of LED Matrix Week 2 Hardware Implementaion Use of Flips Flops, Counters, Clocks and Latches Synicrnoization between LED Matrix and other componants. Week 3 Implementation of incremental motions of snake Length of the snake Variable speed Week 4 Additional feature like LED Pattrens at the start and end using multiplexing. Smooth movement by avoiding abrupt turns Week 5 Food generation. Scoring system of the food. Neatness of the project. TECHNICAL ISSUES FACED Firstly, the most disturbing issue faced by our group was that we had extensively large circuit and it was breathtaking to debug it if the desired result was not obtained during the testing phase. We cracked this problem with the help of colour coding and using labelled wires. Most importantly, we had a working Proteus simulation in front of us, so wherever lost, we grasped help from that. Secondly, the design of the controller was not an easy task. The design was intriguing since there were five controlling variables and we had to cut that down to two variables. Along with that we had to take care of the legality of the moves from the user side. This task employed some critical thinking and in the end our group was able to overcome the problem by using a 2-to-4 line decoder, couple of OR gates and couple of SR latches. Thirdly, when we tried to implement the time permits module, we were not sure how to add food generation logic in the circuit and the execution of this step was pertinent problem because our circuit had little space for anything else. We dominated this issue by using a separate logic to implement this task, i.e. rotation with the help of Shift registers through which were successfully able to generate food. Finally, we added a counter and testing unit to detect the food eating condition of the snake to accomplish the implementation of our scoring problem. Fourthly, we had to incorporate multiplexing in our project to generate the LED patterns. We learnt the ROM writing and using technique taught in the lab with a little help from the supervisor, we were able to overcome this hurdle.
Group 14 5 PROTEUS SCREENSHOTS Figure 1: Schematic for snake game circuit Figure 2: Schematic for multiplexing circuit
Group 14 6 TRUTH TABLES FOR CONTROLLER S OPERATIONS Controller using 2-to-4 line decoder Input Output Lines Lines I 2 I 1 Switch A Switch B 0 0 1 0 Vertically Upwards 0 1 1 1 Move to the left (horizontally) 1 0 0 1 Move to the right (horizontally) 1 1 0 0 Vertically Downwards SR latch for column operations Input Output Lines Lines I 2 I 1 R S 0 0 0 0 0 1 0 1 1 0 1 0 1 1 0 0 SR latch for row operations Input Output Lines Lines I 2 I 1 R S 0 0 0 1 0 1 0 0 1 0 0 0 1 1 1 0