You are on page 1of 34

ECEG 4002 SEMISTER PROJECT

2015/2016 SEMESTER II
MINI PROJECT LONG REPORT
PROJECT TITLE:
ELECTRONIC VOTING MACHINE

UNDER SUPERVISION OF
EN. AREBU D.

CONTENTS
CHAPT
ER
1

ABSTRACT

Pag
e
3

ACKNOWLEDGEMENT

INTRODUCTION

OBJECTIVE

LITERATURE REVIEW

Title

METHODOLOGY
HOW DOES THE
SYSTEM WORK?
LIST OF COMPONENT
HARDWARE
DESCRIPTION
SCHEMATIC DIAGRAM
BLOCK DIAGRAM
FLOW CHART

816

PROBLEM STATEMENT AND


ANALYSIS

17

RESULT AND DISCUSSION

CONCLUSION

1819
20

APPENDIX

2127
2

10

REFERENCE

28

Abstract
Voting is most pivotal process of democratic society
through which people determine its decision. Nowadays
electronic voting machine has become an effective voting
tool compare with traditional paper-based voting schemes.
Flawless voting is ensure by electronic voting machine.
This is the reason it became more widespread. People are
make sure that their vote is secured. One more feature is
that it avoids any kind of malpractice or invalid votes.
Besides that, talking about economic benefits, this system
is more economical than traditional paper-based voting
schemes since the expenditure incurred on manpower is
saved. It is also make voter feels convenient because he
or she has to press only one button of the respective
candidates to vote. Thus, we are decided to design an
electronic voting machine to replace the traditional paperbased voting schemes due to several advantages like
security, automatic counting, economic etc.
This project presents a way to develop an electronic
voting machine by using a 16x2 LCD. The electronic voting
machine contains 4 reset switches which are New Entry
switch, 2 switches for 2 candidates, and a Result switch.
The New Entry switch is to avoid any kind of malpractice
or invalid votes. The New Entry switch is under supervision
and control of a conservator and a user can only vote after
the New Entry is pressed. Besides that, the electronic
voting machine only allows 1 vote for each user. If any
user tries to press the switch multiple times to vote more,
only the first vote will be registered. The 2 switches
represent the respective candidates, voter can vote to the
candidate that he or she desired to vote by press the
switch that represents the candidate. The result will only
display on the LCD screen at the end when the Result
switch is press. So that, the result would not affect the
decision of the voter during the voting process is on the
way. Of course, the Result switch also under supervision
3

and control of a conservator. Finally the number of votes


of respective candidate will display on LCD and we can
know that which candidate is won when the Result switch
is pressed.

Acknowledgement
We would like to express our deepest appreciation to
all those who provided us the possibility to complete this
report. A special gratitude we give to our supervisor,
Arebu D. ,whose contribute in stimulating suggestions and
encouragement, helped us to coordinate our project
especially in writing this report. We also would like to
thanks other lecturers such as Dr. Zaini binti Abdul Halim
and Dr. Syed Sahal Nazli Alhady bin Syed Hassan and the
tutors who guide us during lab sessions so that we applied
it in our mini project which is Electronic Voting Machine.
Moreover, this mini project makes us realized the
value of working together as a team and as a new
experience in working environment, which challenges us
every minute.

We would also like to acknowledge with

much appreciation the staff of Microprocessor Laboratory,


who gave the permission to use all required equipment
and the necessary materials, contributed a great amount
of time as well as guide us to complete our project.
The special thanks goes to partner lab members, who
collaborate each other to assemble the parts and gave
suggestion for our project.

The whole program really

brought us together to appreciate the true value of


friendship

and

respect of each other. We have to

appreciate the guidance given by our seniors and friends


in our project presentation by giving their comments and
5

advices. Last but not least, we appreciate everyone who


help us either directly or indirectly to complete our mini
project.

Introduction
This LCD based electronic voting machine is designed
for two candidates. The input part consists of a set of 4
switches. The switches and 16x2 LCD are interfaced to
microcontroller for various operations and displays. The
provision of casting votes for the candidates has been
provided through 2 of these switches (one for each
candidate). These switches are made active high and
connected to input pins of the controller. The remaining 2
switches are New Entry and Result. The New Entry switch
initializes the voting system when pressed, while the
Result switch ends the voting and displays the result (total
number of votes for respective candidate)and winner on
LCD screen. This system is set to 1 vote for each voter. In
other word, the voter cannot make the second vote even
he or she press the switch as long as the New Entry switch
is press. Besides that, each of the switch has connected to
a 1k ohm resistor and a LED. The resistor act as a pull
down resistor which make the input normal LOW while the
LED is to indicate the switch is being press.
The main objective of this project is to design and
create a general electronic voting machine to replace the
traditional paper-based voting schemes so that we can
take an advantages in term of economic and convenient.
Electronic voting machine is more economic because less
manpower is required and may saves transportation cost
due to its compact size. It is also more convenient and
time conscious as less time required for voting and
counting. Besides that, it is also more secure due to avoid
invalid voting such asa people make a vote twice. Other
than that, paper-based voting can actually miss ballots
due to human mistakes in placing the paper-based ballot
6

in the machine. But, this will be not happen at electronic


voting machine.
The following is the advantages of electronic voting
machine:
1. It is economical
2. Less manpower required
3. Time conscious
4. Avoids invalid voting
5. Convenient
Objectives
To program the Microprocessor 8051 to create an
electronic voting machine.
To interface the Microprocessor 8051 with 2x16 LCD
screen.
To program the Microprocessor for automatic
counting and secured system

Literature Review
According to the electronic voting machine that
designed by others, we found that it is similar to our
design. First of all, their security system has control by 2
buttons. The first switch is New Entry switch to display the
Welcome from thanks after a vote has been casted.
While the second switch is Ready switch to indicate the
voter ready to cast a vote. Then the voter can only cast a
vote after the New Entry is pressed and follow by Ready
button. Our security system is only control by one switch
which is New Entry switch. After a vote has been casted,
our voting machine will be display Welcome
automatically from thanks after some delay. Then the
voter can only cast a vote after the New Entry switch has
pressed. Otherwise, any vote will not be counted. Besides
that, their voting system is designed for 4 candidates and
the counter for number of votes for each candidate can
reach 3-digits number while we had designed for 2
candidates and the counter for number of votes for each
candidate can only reach 2-digits number. But, we can add
the number of candidate and also the counter by modified
the program as well. Due to the time constraints we
designed this as a prototype.
Moreover, we had found that some weakness and
flaw in their system. We found that their electronic voting
machine will display the number of votes for respective
candidates after a vote has been casted. This phenomena
8

may cause an unfair election happen due to the voter


could tell the next voter about the result. This may affect
the decision of other voters. Besides that, the guideline of
the message that shown on LCD display not really clear.
The LCD screen will display nothing when the period for
voter ready to cast their vote. This may confused the
users of this voting machine.
Thus, we are enhance the system by hide the
number of votes for each candidates as long as the Result
button is pressed. Once the result are out, the voting
process is end and the LCD screen will declare the winner.
Next, we also enhance the guideline of the system by
adding the message Please vote during the period for
voter ready to cast a vote. So that the voter would not be
confused.

Methodology
How does it works?
First, the LCD screen will always display Welcome to
vote! as long as the voting is started by pressing the New
Entry switch after which the user is prompted to vote.
Then, the LCD screen will display Please vote to
indicate the voter could start to cast a vote. The count of
votes is stored in two different variables. As soon as the
user votes for a candidate by pressing one of the switches,
the value of the corresponding variable is increased by
one. After this, a Thank you message is displayed on LCD
to acknowledge the registration of users vote and the LCD
screen will be automatically display back Welcome to
vote! after some delay. The message will be stays on the
screen until the next voter come and a conservator
presses the New Entry switch. Then the voters have to
press the switch to cast another vote and finally the Result
switch is pressed to get the poll results. When the Result
button is pressed the names of the candidates are
displayed along with their vote counts. After some delay,
the result is displayed which could be either declaration of
the winner candidate or the candidates with a clash of
their number of votes.

Component List
Component/Equipment
8051 Development System
Light Emitted Diode (LED)
Reset Button Switch
1k ohm Resistor
2x16 LCD Screen

Quantity
1
4
4
4
1

10

Hardware Description
Microcontroller board 8051
The 8051 Microcontroller was designed in 1980s
by Intel. Its foundation was on Harvard
Architecture and was developed
principally for bringing into play in
Embedded Systems. At first it was
created
by
means
of
NMOS
technology but as NMOS technology
needs more power to function therefore Intel re-intended
Microcontroller 8051 employing CMOS technology and a
new edition came into existence with a letter C in the
title name, for illustration: 80C51. These most modern
Microcontrollers need fewer amount of power to function
in comparison to their forerunners.
There are two buses in 8051 Microcontroller one for
program and other for data. As a result, it has two storage
rooms for both program and data of 64K by 8 size. The
microcontroller comprise of 8 bit accumulator & 8 bit
processing unit. It also consists of 8 bit B register as
majorly functioning blocks and 8051 microcontroller
programming is done with embedded C language using
Keil software. It also has a number of other 8 bit and 16 bit
registers.
For internal functioning & processing Microcontroller 8051
comes with integrated built-in RAM. This is prime memory
and is employed for storing temporary data. It is
unpredictable memory i.e. its data can get be lost when
the power supply to the Microcontroller switched OFF.

11

8051 Pin Diagram & Description


For describing pin diagram and pin configuration of 8051,
we are taking into consideration a 40 pin DIP (Dual inline
package). Now lets go through pin
configuration in detail.
Pin-40 : Named as Vcc is the main
power source. Usually its +5V DC.
You may note some pins are
designated with two signals (shown in
brackets).
Pins 32-39: Known as Port 0 (P0.0 to
P0.7) In addition to serving as I/O
port, lower order address and data
bus signals are multiplexed with this
port (to serve the purpose of external
memory interfacing). This is a bi
directional I/O port (the only one in
8051) and external pull up resistors
are required to function this port as
I/O.
Pin-31:- ALE aka Address Latch Enable is used to
demultiplex the address-data signal of port 0 (for external
memory interfacing.) 2 ALE pulses are available for each
machine cycle.
Pin-30:- EA/ External Access input is used to enable or
disallow external memory interfacing. If there is no
external memory requirement, this pin is pulled high by
connecting it to Vcc.
Pin- 29:- PSEN or Program Store Enable is used to read
signal from external program memory.
Pins- 21-28:- Known as Port 2 (P 2.0 to P 2.7) in addition
to serving as I/O port, higher order address bus signals are
multiplexed with this quasi bi directional port.
Pin 20:- Named as Vss it represents ground (0 V)
connection.
12

Pins 18 and 19:- Used for interfacing an external crystal to


provide system clock.
Pins 10 17:- Known as Port 3. This port also serves some
other functions like interrupts, timer input, control signals
for external memory interfacing RD and WR , serial
communication signals RxD and TxD etc. This is a quasi bi
directional port with internal pull up.
Pin 9:- As explained before RESET pin is used to set the
8051 microcontroller to its initial values, while the
microcontroller is working or at the initial start of
application. The RESET pin must be set high for 2 machine
cycles.
Pins 1 8:- Known as Port 1. Unlike other ports, this port
does not serve any other functions. Port 1 is an internally
pulled up, quasi bi directional I/O port.
Microcontroller board 8255
The Intel 8255A is a general
purpose programmable I/O device
which is designed for use with all
Intel and most other
microprocessors. It provides 24 I/O
pins which may be individually
programmed in 2 groups of 12 and
used in 3 major modes of
operation. In MODE 0, each groups of 12 I/O pins may be
programmed in sets of 4 and 8 to be inputs or outputs. In
MODE 1, each group may be programmed to have 8 lines
of input or output. 3 of the remaining 4 pins are used for
handshaking and interrupt control signals. MODE 2 is a strobed bidirectional bus configuration. The 8255 is a 40 pin integrated circuit
(IC), designed to perform a variety of interface functions in a
computer environment. The 8255 wasnt originally designed to be
connected to the Z80. It was manufactured by Intel for the 8080
microprocessor.

13

D0 - D7 These are the data input/output


lines for the device. All information read
from and written to the 8255 occurs via
these 8 data lines.
CS (Chip Select Input). If this line is a
logical 0, the microprocessor can read
and write to the 8255.
RD (Read Input) Whenever this input line
is a logical 0 and the RD input is a logical
0, the 8255 data outputs are enabled
onto the system data bus.
WR (Write Input) Whenever this input
line is a logical 0 and the CS input is a logical 0, data is
written to the 8255 from the system data bus
A0 - A1 (Address Inputs) The logical combination of these
two input lines determines which internal register of the
8255 data is written to or read from.
RESET The 8255 is placed into its reset state if this input
line is a logical 1. All peripheral ports are set to the input
mode.
PA0 - PA7, PB0 - PB7, PC0 - PC7 These signal lines are used
as 8-bit I/O ports. They can be connected to peripheral
devices. The 8255 has three 8 bit I/O ports and each one
can be connected to the physical lines of an external
device. These lines are labelled PA0-PA7, PB0-PB7, and
PC0-PC7. The groups of the signals are divided into three
different I/O ports labelled port A (PA), port B (PB), and
port C (PC).
LCD2x16

The Serial LCDs are very


functional, liquid crystal
displays that can be
easily interfaced to and
controlled by a microcontroller using an I/O pin. The LCD
displays provide basic text wrapping so that your text
14

looks correct on the display. Full control over all of their


advanced LCD features allows you to move the cursor
anywhere on the display with a single instruction and turn
the display on and off in any configuration. They support
the same visible characters as the Terminal (ASCII Dec 32127). In addition, you may define up to eight of your own
custom characters to display anywhere on the LCD. This
device can be connected to a PC serial port using a
MAX232 line driver. The circuit isn't supported by us.
Resistor
Resistor
terminal

is

passive

components

two
which

widely use in the circuit. Its function is to limit the current


of the circuit. In this miniproject, we used 4 1k resistors
as a pull down resistor for the 4 reset buttons.It also used
as a safety mechanism if a circuit exceeds safe margins.

LED
Light-Emitting Diode (LED) is a
basic component we widely use
in the circuit. It usually connect
in series with resistor to emit
light.

We

used

the

LED

to

indicate the reset buttons have pressed.

Reset Button
15

In electronics and technology, a reset


button is a button that
can reset a device. On video game
consoles. Reset buttons are found
on circuit breakers to reset the circuit.
This button can cause data corruption
so this button often doesn't exist on
many machines. Usually, in
computers and other electronic
devices, it is present as a small
button, possibly recessed into the
case or only accessible by a pin or
similar thin object, to prevent it being
pressed accidentally.

16

SCHEMATIC DIAGRAM

17

BLOCK DIAGRAM FOR


ELETRONIC VOTING MACHINE
A block diagram is drawn to ease the understanding to
connection of circuit design. This block diagram explains
roughly about the connection of the microcontroller 8051,
PPI 8255, 2x16 LCD screen and LEDs. Based on this block
diagram, we write the program code according to our
circuit design.

805
1

825
5

4
switches/res
et buttons
4 LEDs
2x16
LCD

18

Flow Chart
Sta
rt

LCD display:
WELCOME TO
VOTE!

Is the New Entry switch being press?


YES

Is the Result switch being press?


N
O

YES

LCD display:
PLEASE

LCD
display:
C1

AFTER A

XX>
NO

Is the switch
that
represent

YES

Is the switch
that
represent
C2 being
The number
YES
of
votes for C2

XX<

LCD display:
CONGRATULATI
ON!!

LCD display:
CONGRATULATI
XX=Y
ON!!

The number
of

AFTER A

NO

LCD display:
DRAW!! PROCEED TO THE NEXT
VOTING...
LCD display:
THANK

19

Problem Statement and


Analysis
Problem 1:
When we display those message on LCD screen, we
found that the cursor on LCD screen keep on moving and
it is too annoying for the user.
Solution:
We change the command to LCD from 0E(display on,
cursor on) to 0C(display on, cursor off).
Problem 2:
We are going to display the number of votes of
candidate that have stored in register on LCD screen.
Then, we realise that the LCD display the other character
instead of the number.
Solution:
We found that LCD can only read ASCII code and the
number that stored in the register is HEX code. By refer to
the table of comparison between ASCII code and HEX
code, we found that we could convert the HEX code to
ASCII code by adding 30H for the numbering part. In other
word, 30H will display 0 on LCD, 31H will display 1 on LCD.
Problem 3:
After we solved the problem 2, we are facing the
other problem that we can only display the single digit (09) to LCD screen due to only 0-9 available on ASCII code.
Double digits such as 17, 23 will display the other
characters on LCD.
Solution:
First we move the number that stored in the register
to Accumulator and move 10H to register B. After that, we
use the function DIV AB and move the content of A and B
to another 2 registers follow by add 30H for both registers
and finally display on LCD screen.
20

Example:
23H
A, 10H
B
DIV AB
A=2, B=3
A
R5+30H, B
R6+30H

21

Result And Discussion


First of all, the electronic voting machine will be
starting by display WELCOME TO VOTE! as shown in
figure below as long as the New Entry switch is being
pressed. The switch 1 represented New Entry switch and
switch 4 represented Result switch. While the switch 2 and
3 represented candidate 2 and 3.

Switch

Switch

Switch

Switch

After that, the LCD screen will display PLEASE VOTE


immediately to indicate the voter could start to cast their
vote. The result is shown in
figure below.

22

23

After the voting process is ended, the Result switch is


being pressed by a conservator. Then all the candidates
follow by the number of votes will be display on LCD
screen and after some delay it would declare the winner
automatically.

Result

Declare The
Based on the figures above candidate1 (C1) get 18 votes
while candidate2 (C2) only 11 votes. So C1 has wins the
poll and the LCD screen will make a congratulation and
declare that C1 wins! Conversely the LCD screen will
display C2 wins if the number of votes for C2 is more
than C1. In case of the number of votes for both
candidates clash, the LCD screen will ask for proceed to
another voting.
In this project, we still require to make some
improvement to make it more effective for future scope.
First, we can make an option initially to choose how much
the candidate will be involved. Next, in security system,
we could add a finger print scanning to mark down the
people who has voted to ensure that a same people
cannot vote for the second times. We can also provide
several different languages to voters for whom English is
not the first language. Finally, there are also advantages
when it comes to disabled people, such as blind
individuals. Electronic voting machine can provide
headphones to read off instructions to blind voters.
Additional tools can be incorporated into these voting
machines to help with other disabilities and to aid the
elderly as well. Due to time constraints we have not been
24

able to implement these features in our project. But it is


possible to make it in the future.

25

Conclusion
This project show that we can use the microcontroller
8051 to design a electronic voting machine which is more
secured, convenient, and economic compare with the
traditional
paper-based
voting
scheme.
We
are
successfully build up an electronic voting machine which
can be used for school and college level council elections
or any voting purpose event.The function of the circuit is
working according to what are we predicted and the
objectives is achieve. This show that our program code
and circuit design can be implemented to a real life
In this project, we learned some extra code of
microcontroller 8051 which we did not learn from the lab
session and we are able to use those code. For an
instance, we had used the registers from Bank 1 and the
alternative way to display a message on LCD screen. We
learned how to interface the microcontroller 8051 with PPI
8255, LCD screen, and LED. We are able to use the ports
from PPI 8255 to send an output from microcontroller 8051
or send an input to microcontroller 8051. We learned how
to solve the problem that we faced during this project.
We hope that our project will not only work on our
circuit design, but also it can work in a real life by do some
improvement on it. So that it could be used for voting
purpose at any required place.

26

Appendix
Assembly program code:
CPU"8051.TBL"
INCL"8051.INC"
MOV SP, #030H
ORG 2000H
PA: EQU 4000H
PB: EQU 4001H
PC: EQU 4002H
PCTR: EQU 4003H
MOV A, #10010000B
MOV DPTR, #PCTR
MOVX @DPTR, A
MOV A, #38H
LCALL COMNWRT
LCALL DELAY
MOV A, #0CH
LCALL COMNWRT
LCALL DELAY
MOV A, #10H
LCALL COMNWRT
LCALL DELAY
MOV A, #01H
LCALL COMNWRT
LCALL DELAY
MOV R0, #0H
MOV R6, #0H
MOV R1, #0H
MOV R2, #0H
MOV R3, #0H
MOV R4, #0H
MOV R5, #0H
MOV R7, #0H
SETB F0
;
=============================================
==============================;
;
=============================================
==============================
START:
LCALL BUTTONPRESS
LCALL FIRSTLINE
LCALL SECONDLINE
CJNE R0, #2, START1
MOV R0, #0
LCALL DELAY1
LCALL DELAY1
27

START1:

LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
CJNE R0, #3, START
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
LCALL DELAY1
LCALL WINNER
SJMP AGAIN

AGAIN:
;
=============================================
==============================;
SCAN BUTTON
;
=============================================
==============================
BUTTONPRESS:
MOV DPTR, #PA
MOVX A, @DPTR
ANL A, #00001111B
CJNE A, #00000001B, RCHECK1
MOV R0, #1
CLR F0
RET
RCHECK1:

CJNE A, #00000010B, RCHECK2


JB F0, DONTH
INC R1
MOV R0, #2
SETB F0
RET

RCHECK2:

CJNE A, #00000100B, RCHECK3


JB F0, DONTH
INC R2
MOV R0, #2
SETB F0
RET

RCHECK3:

CJNE A, #00001000B, DONTH


MOV R0, #3
RET
28

DONTH:
RET
;
=============================================
==============================
;
DISPLAY MESSAGES ON LCD
;
=============================================
==============================
FIRSTLINE: LCALL DELAY
MOV A, #80H
LCALL COMNWRT
LCALL DELAY
MOV R4, #0
LOOP1:

MOV A, R4
LCALL COND0
MOVC A, @A+DPTR
INC R4
JZ PROCEED1
LCALL DATAWRT
LCALL DELAY
SJMP LOOP1

PROCEED1: RET
;
=============================================
==============================
;
DISPLAY THE TOTAL NUMBER OF VOTES
;
=============================================
==============================
SECONDLINE:
MOV DPTR, #PA
MOVX A, @DPTR
ANL A, #00001000B
CJNE A, #00001000B, DONTH1
MOV A, #0C0H
LCALL COMNWRT
LCALL DELAY
MOV A, R1
MOV R7, A
LCALL HEXTOBCD
MOV A, R5
ADD A, #30H
LCALL DATAWRT
LCALL DELAY
MOV A, R6
ADD A, #30H
LCALL DATAWRT
LCALL DELAY
MOV A, #20H
29

LCALL DATAWRT
LCALL DELAY
MOV A, #20H
LCALL DATAWRT
LCALL DELAY
MOV A, R2
MOV R7, A
LCALL HEXTOBCD
MOV A, R5
ADD A, #30H
LCALL DATAWRT
LCALL DELAY
MOV A, R6
ADD A, #30H
LCALL DATAWRT
LCALL DELAY
RET
DONTH1:
RET
;
=============================================
==============================;
DECLARE
WINNER
;
=============================================
==============================
WINNER:
CLR C
MOV A, #01H
LCALL COMNWRT
LCALL DELAY
MOV A, #80H
LCALL COMNWRT
LCALL DELAY
MOV R4, #0
LOOP2:

MOV A, R1
MOV 50H, R2
CJNE A, 50H, LOOP3
LCALL COND6
MOV A, R4
MOVC A, @A+DPTR
INC R4
JZ PROCEED2
LCALL DATAWRT
LCALL DELAY
SJMP LOOP2

LOOP3:

JC LOOP4
MOV A, R4
LCALL COND4
MOVC A, @A+DPTR
INC R4
JZ PROCEED2
30

LCALL DATAWRT
LCALL DELAY
SJMP LOOP3
LOOP4:

MOV A, R4
LCALL COND5
MOVC A, @A+DPTR
INC R4
JZ PROCEED2
LCALL DATAWRT
LCALL DELAY
SJMP LOOP4

PROCEED2: MOV R0, 255


MOV A, #18H
LCALL COMNWRT
LCALL DELAY1
LCALL DELAY
DEC R0
MOV A, R0
JNZ PROCEED2
RET
;
=============================================
==============================;
SELECT WHICH
MESSAGE TO BE DISPLAY
;
=============================================
==============================
COND0:
CJNE R0, #0, COND1
MOV DPTR, #MSG0
RET
COND1:

CJNE R0, #1, COND2


MOV DPTR, #MSG1
RET

COND2:

CJNE R0, #2, COND3


MOV DPTR, #MSG2
RET

COND3:

MOV DPTR, #MSG3


RET

COND4:

MOV DPTR, #MSG4


RET

COND5:

MOV DPTR, #MSG5


RET

COND6:

MOV DPTR, #MSG6


RET

31

;
=============================================
==============================; CONVERT HEX TO BCD
;
=============================================
==============================
HEXTOBCD: CLR C
MOV A, R7
MOV B, #10
DIV AB
MOV R5, A
MOV R6, B
RET
;
=============================================
==============================; LCD COMMAND
;
=============================================
==============================
COMNWRT: MOV DPTR, #PC
MOVX @DPTR, A
CLR P1.0 ;RS
CLR P1.1 ;RW
SETB P1.2;E
ACALL DELAY
CLR P1.2
RET
DATAWRT:

MOV DPTR, #PC


MOVX @DPTR, A
SETB P1.0
CLR P1.1
SETB P1.2
ACALL DELAY
CLR P1.2
RET

;
=============================================
==============================;
DELAY
;
=============================================
==============================
DELAY:
MOV R3, #225
HERE1:
DJNZ R3, HERE1
32

RET
DELAY1:
HERE:
HERE2:

SETB PSW.4
MOV R7, #255
MOV R3, #255
DJNZ R3, HERE2
DJNZ R7, HERE
CLR PSW.4
RET

;
=============================================
==============================;
DECLARE
MESSAGE TO BE DISPLAY ON LCD
;
=============================================
==============================
ORG 3800H
MSG0: DFB "WELCOME TO VOTE!", 0H
ORG 3830H
MSG1: DFB "PLEASE VOTE... ", 0H
ORG 3850H
MSG2: DFB "THANK YOU...
ORG 3870H
MSG3: DFB "C1 C2

", 0H

", 0H

ORG 3890H
MSG4: DFB "CONGRATULATION!! C1 WINS!!!", 0H
ORG 3910H
MSG5: DFB "CONGRATULATION!! C2 WINS!!!", 0H
ORG 3950H
MSG6: DFB " DRAW!! PROCEED TO THE NEXT VOTING...", 0H
END

A prototype of electronic voting machine which designed


by our group.

33

REFERENCE
1.
http://www.electronics.dit.ie/staff/tscarff/8255PPI/8255.htm
2. http://www.circuitstoday.com/8051-microcontroller
3. http://en.wikipedia.org/wiki/Intel_8255
4.http://www.cdrummond.qc.ca/cegep/informat/professeur
s/alain/files/asc ii.htm
5. Laboratory Manual EEE226 Microprocessor I
6. The 8051 Microcontroller and Embedded Systems
7. Appendix 8051 Instructions, Timing, And Registers

34

You might also like