i
THE DESIGN OF A GUESSWORD GAME VIA PIC MICROCONTROLLER
AHMAD SYAZNAN BIN MOHD ASRI
This report is submitted in partial fulfillment of the requirements for the award of Bachelor of Electronic Engineering (Industrial Electronic) with Honours.
Faculty of Electronic Engineering and Computer Engineering Universiti Teknikal Malaysia Melaka
UNIVERSTI TEKNIKAL MALAYSIA MELAKA
FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER
BORANG PENGESAHAN STATUS LAPORAN PROJEK SARJANA MUDA II
Tajuk Projek : The Design of a Guessword Game via Pic Microcontroller Sesi
Pengajian : 1 0 / 1 1
Saya AHMAD SYAZNAN BIN MOHD ASRI
mengaku membenarkan Laporan Projek Sarjana Muda ini disimpan di Perpustakaan dengan syarat-syarat kegunaan seperti berikut:
1. Laporan adalah hakmilik Universiti Teknikal Malaysia Melaka.
2. Perpustakaan dibenarkan membuat salinan untuk tujuan pengajian sahaja.
3. Perpustakaan dibenarkan membuat salinan laporan ini sebagai bahan pertukaran antara institusi
pengajian tinggi.
4. Sila tandakan ( √ ) :
SULIT* *(Mengandungi maklumat yang berdarjah keselamatan atau kepentingan Malaysia seperti yang termaktub di dalam AKTA RAHSIA RASMI 1972)
TERHAD** **(Mengandungi maklumat terhad yang telah ditentukan oleh organisasi/badan di mana penyelidikan dijalankan)
TIDAK TERHAD
Disahkan oleh:
__________________________ ___________________________________
(TANDATANGAN PENULIS) (COP DAN TANDATANGAN PENYELIA)
iii
“I hereby declared that this report entitled The Design of a Guessword Game via PIC Microcontroller is a result of my own work except for the works that have been cited clearly in the references”
Signature : ……….
iv
“I hereby declared that I have read this report and in my opinion this report is sufficient in terms of the scope and quality for the award the Bachelor of Electronic Engineering
(Industrial Electronic) with Honours”
Signature : ……….
v
Special dedicated to my beloved parents, family, friends and lecturers, who had strongly encouraged, inspired and supported me in my entire journey of education.
vi
ACKNOWLEDGEMENT
First of all, I would like to extend my deepest grateful to grace and mercy Allah S.W.T for giving me strength and determined to complete my thesis entitled “The Design of a Guessword Game via PIC Microcontroller”. I would also like to take this opportunity to express my deep and all my sincere gratitude towards my honorable supervisor, Engr. Zarina Binti Mohd Noh, for her guidance, encouragement, and motivation, I manage to finish the Bachelor Degree Project program properly. Without the continued support and interest, this thesis would not have been the same as presented here. My deepest gratitude goes to two most important people who always given their loves and support, Ibu and Ayah; i-thank-you's will never seems enough to depict my appreciation. To my dear friends, thank you for sharing all the knowledge which I applied in this project. Thank you very much.
ABSTRACT
ABSTRAK
Secara keseluruhannya, projek ini bertujuan untuk menjadikan ciri-ciri didalam
Programmable Interface Controller(PIC) sebagai sistem utama dalam penghasilan
permainan teka perkataan ini. Projek ini menerangkan asas pembinaan permainan teka perkataan dengan menggunakan PIC, Liquid Crystal Display(LCD) sebagai paparan dan
Keypad sebagai masukkan data. Peranti input yang digunakan adalah keypad 4x3 dan
ix
CONTENTS
CHAPTER TITLE PAGE
PROJECT TITLE i
REPORT STATUS FORM ii
DECLARATION iii
APPROVAL iv
DEDICATION v
ACKNOWLEDGEMENT vi
ABSTRACT vii
ABSTRAK viii
CONTENTS ix
LIST OF TABLES xii
LIST OF FIGURES xiii
LIST OF ABBREVIATIONS xv
LIST OF APPENDIX xvi
1 INTRODUCTION
1.1 Introduction 1
1.2 Objectives 4
x
1.4 Scope Of Project 4
1.5 Methodology 5
1.6 Report Structure 7
2 LITERATURE REVIEW
2.1 Introduction 8
2.2 Microcontroller 8
2.2.1 Decision For Choose Microcontroller 9
2.3 PIC16F877A 10
2.3.1 Power Supply 12
2.3.2 Voltage Regulator 12
2.3.3 Clock Oscillator 12
2.3.4 Programming The PIC16F887A 13
2.4 LCD 15
2.5 Keypad 16
2.5.1 4x3 Keypad 17
2.6 MicroC 19
3 METHODOLOGY
3.1 Introduction 21
3.2 Project Methodology 21
3.2.1 Flowchart of Project 22
3.3 Literature Review 24
3.4 Software Implementation and Programming 24 3.4.1 Algorithm and Programming in MikroC PRO
for PIC 25
3.4.2 MicroC 26
3.5 Testing 27
xi
3.6.1 Voltage regulator (5 V) 27
3.6.2 LCD Module (20x4) Character 28 3.6.3 Microcontroller PIC 16F877A 29
3.6.4 4x3 Keypad 29
4 RESULT AND DISCUSSION
4.1 Introduction 31
4.2 Hardware-User Interface 32
4.3 Software Analysis 32
4.4 Hardware Analysis 38
4.4.1 Power Supply Circuit 38
4.4.2 Microcontroller Circuit 39
4.4.3 LCD Interface 39
4.4.4 Keypad Interface 41
4.5 Overview of The Complete Hardware 43
4.6 Discussion 44
4.7 Project Overview 47
5 CONCLUSION AND RECOMMENDATION
5.1 Introduction 48
5.2 Conclusion 48
5.3 Recommendation 50
xii
LIST OF TABLES
NO. TITLE PAGE
1 PIC library 14
2 The pin assignment for LCD 16
xiii
LIST OF FIGURES
NO. TITLE PAGE
1 Tennis for two 2
2 Flow Chart for Project Methodology 6
3 Basic microcontroller system 9
4 The on board peripherals as a guide in connecting the output and input
of this microcontroller 11
5 PIC Microcontroller power supply 12
6 LCD 20 x 4 15
7 4x3 keypad 17
8 keypad switch layout 17
9 keypad connection to microcontroller 19
10 MicroC IDE 20
11 Flow chart of the project 22
12 Flow chart of design process 23
13 MicroC software Tool 26
14 20x4 LCD display 28
15 8 pins (4x3 keypad) 30
16 3x4 keypad 30
17 Full functional block diagram 32
18 Simulation using proteus 7 professional software 33
xiv
20 Flowchart of the Programming 34
21 Shows the character message “Welcome to Word Guessing Game” on
The welcome screen 35
22 Shows the word that need to be guess 35
23 Shows the input from the user 36
24 Shows the input word from the user 36
25 Shows the display result if the result is right 37 26 Shows the display result if the result is wrong 37
27 Voltage regulator Circuit 38
28 Clock Oscillator circuit 39
29 Connection for LCD 40
30 Connection for Keypad 41
31 Pin description for 4 x 3 keypad 42
32 PCB layout design using the ARES Professional 43
33 The complete etching circuit 43
34 Complete Circuit 44
35 LCD cannot display the word character 45
36 SK40C module from Cytron 46
xv
LIST OF ABBREVIATIONS
ADC Analog-Digital Converter
EEPROM Electrically Erasable Programmable Read-Only Memory ISR Interrupt Service Routine
LCD Liquid crystal display
PIC Programmable Interface Controller RAM Random-access memory
ROM Read Only Memory
xvi
LIST OF APPENDIX
1
CHAPTER I
INTRODUCTION
1.1 Introduction
This chapter will discuss about the introduction, objectives, scope and methodology of the project.
The origin of video games lies in early cathode ray tube-based missile defense systems in the late 1940s. These programs were later adapted into other simple games during the 1950s. By the late 1950s and through the 1960s, more computer games were developed (mostly on mainframe computers), gradually increasing in sophistication and complexity. Following this period, video games diverged into different platforms: arcade, mainframe, console, personal computer and later handheld games. [1]
2
[image:18.612.184.474.291.507.2]University of Cambridge, in order to demonstrate his thesis on human-computer interaction. It was developed on the EDSAC computer, which uses a cathode ray tube as a visual display to display memory contents. The player competes against the computer. In 1958 William Higinbotham created a game using an oscilloscope and analog computer. Titled Tennis for Two, it was used to entertain visitors of the Brookhaven National Laboratory in New York. Tennis for Two showed a simplified tennis court from the side, featuring a gravity-controlled ball that needed to be played over the "net," unlike its successor. The game was played with two box-shaped controllers, both equipped with a knob for trajectory and a button for hitting the ball. Tennis for Two was exhibited for two seasons before its dismantlement in 1959.[2]
Figure 1.1: Tennis for two
3
programmable cartridges). This provided the ability to play several different games using the same system, along with plastic sheet overlays taped to the television that added color, play-fields, and various graphics to 'interact' with using the electronic images generated by the system.
In the earliest consoles, the computer code for one or more games was hardcoded into microchips using discrete logic, and no additional games could ever be added. By the mid-1970s video games were found on cartridges, starting in 1976 with the release of the Fairchild 'Video Entertainment System (VES). Programs were burned onto ROM chips that were mounted inside plastic cartridge casings that could be plugged into slots on the console. When the cartridges were plugged in, the general-purpose microprocessors in the consoles read the cartridge memory and executed whatever program was stored there. Rather than being confined to a small selection of games included in the game system, consumers could now amass libraries of game cartridges. However video game production was still a niche skill. Warren Robinett, the famous programmer of the game Adventure, spoke on developing games "in those old far-off days, each game for the 2600 was done entirely by one person, the programmer, who conceived the game concept, wrote the program, did the graphic, drawn first on graph paper and converted by hand to hexadecimal and did the sounds.".[4]
4
1.2 Objectives
The main objectives for this project are:
I. To gain knowledge in interfacing between keypad, microcontroller and LCD
II. To design an algorithms(programming code) for the guess word game III. To create a database of word via PIC registers
IV. To develop the input and output circuit related for the gaming system
1.3 Problems Statement
A Programmable Interface Controller (PIC) was widely use in the electronic devices and giving many benefits in nowadays life, such as measurement and control of parameters in industry. One of the applications of the PIC is for Online Monitoring and Fiber Fault Identification in optical fiber communication. [5] Thus the purpose of this project is to explore the properties of PIC as the main controller for gaming purpose.
1.4 Scope of Project
5
program is written to initialize the PIC, set the input port, receive the input from the keypad, and process the input and lastly displaying the result to the LCD. [6]
1.5 Methodology
6
7
1.6 Report Structure
This report shall explain the first part of the final year project, which is the research. What is done thus far is compiled in this report. This report is going to be the reference point with which it is going to be used in the next part of this project. All of contents of this report are useful to fast pacing this project to the next level. So it is important that the contents of this report to be thoroughly researched and put into place.
Chapter 1: introduces the project as a whole. The early and basic explanations are mentioned in this chapter. This chapter consists of the project’s objectives, statements of problems, scope of work, and the simplified methodology.
Chapter 2 is literature review. Past projects or researches are taken into consideration when completing this chapter. The ways those projects and researches are done are compared with what this project is all about. These comparisons are done to understand what this project is all about and where it stands.
Chapter 3 explains how this project came to be. It is the methodology which is the project procedure. This chapter will enlighten the part most important of all, the flow this project. What is researched and what needs to be done is explained in this chapter.
Chapter 4 concentrates on the result and discussion of this project. What has been done thus far is explained in diagrams and written programs. Why the results are like so will also be explained. The reasons and setbacks that cause the project to be halted are discussed in this chapter. The expected results will also be mentioned in this chapter.
8
CHAPTER II
LITERATURE REVIEW
2.1 Introduction
This chapter will discuss about theory and concepts of the project in detail to explain perspective and method that being used in the past research and survey how far this project related with the research and theory that already have. Besides that, this chapter also will show the theory and concepts that being used to solve project problem. Understanding about the theory is very important as a guide line through-out the research.
2.2 Microcontroller