Top Banner
LCD BASED VOTING MACHINE USING 8051 MICROCONTROLLER ACKNOWLEDGEMENT It is indeed of great pleasure and proud privilege to be able to present the project on “Lcd Based Voting Machine Using 8051” The completion of project work is a milestone in student’s life and its execution is inevitable in the hands of guide.we highly indebt the project guide Mr.Prasad Dhuri for this invaluable guidance and appreciation for giving form and substance to this project.it is due to his enduring efforts, patience and enthusiasm, which has given a sense of direction and purposefulness to this project and ultimately made it a success. We would like to tender our sincere thanks to the staff members for their co-operation. We would also like to express our deep regards and gratitude to the principal Dr.Varsha Shah, our HOD Prof. Nargis Shaikh. We would also like to thank the non teaching staff and our friends who have helped us all the time in the way or the other. LIST OF CONTENT LCD BASED VOTING MACHINE USING 8051 MICROCONTROLLER 1. Introduction 08 2. Circuit diagram 09 3. Components 11 4.Program for IC 15 5.Working 30 6.PCB layout 31 7.Advantages 32 8.Future Scope 33 VENDING MACHINE 1.Introduction 36 2. Flowchart 37 3. Working 38 4. VHDL code 40 5.Output Waveforms 44 6.Applications & uses 45 REFRENCES 47 LCD BASED VOTING MACHINE USING 8051 MICROCONTROLLER INTRODUCTION This LCD based electronic voting machine is designed for four candidates. The input part consists of a set of six tactile switches. The switches and 16x2 LCD are interfaced to microcontroller AT89C51 for various operations and displays.
23

Lcd Based Voting Machine

Oct 24, 2015

Download

Documents

MOHAMMED ASIF

lcd based voting machine
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lcd Based Voting Machine

LCD BASED VOTING MACHINE

USING 8051 MICROCONTROLLER

ACKNOWLEDGEMENT

It is indeed of great pleasure and proud privilege to be able to present the project on “Lcd Based Voting Machine Using 8051”

The completion of project work is a milestone in student’s life and its execution is inevitable in the hands of guide.we highly indebt the project guide Mr.Prasad Dhuri for this invaluable guidance and appreciation for giving form and substance to this project.it is due to his enduring efforts, patience and enthusiasm, which has given a sense of direction and purposefulness to this project and ultimately made it a success.

We would like to tender our sincere thanks to the staff members for their co-operation.

We would also like to express our deep regards and gratitude to the principal Dr.Varsha Shah, our HOD Prof. Nargis Shaikh.

We would also like to thank the non teaching staff and our friends who have helped us all the time in the way or the other.

LIST OF CONTENT

LCD BASED VOTING MACHINE USING 8051 MICROCONTROLLER

1.Introduction 082.Circuit diagram 093.Components 114.Program for IC 155.Working 306.PCB layout 317.Advantages 328.Future Scope 33VENDING MACHINE1.Introduction 362.Flowchart 373.Working 384.VHDL code 405.Output Waveforms 446.Applications & uses 45REFRENCES 47

LCD BASED VOTING MACHINE

USING 8051 MICROCONTROLLER

INTRODUCTION

This LCD based electronic voting machine is designed for four candidates. The input part consists of a set of six tactile switches. The switches and 16x2 LCD are interfaced to microcontroller AT89C51 for various operations and displays.

Page 2: Lcd Based Voting Machine

The provision of casting votes for the candidates has been provided through four of these switches. These switches are made active high and connected to pins 2-5 (P1^1 – P1^4) of the controller. The remaining two switches (both active low) are to start and stop the voting procedure. They are connected to pins 1 and 6 (P1^0 and P1^5) respectively. The Init (start) switch initializes the voting system when pressed, while the

Stop switch ends the voting and displays the poll results on LCD screen.

For more details on working with LCD, refer LCD interfacing with 8051. The data pins of the LCD (pins 7-14) are connected to the output port P2 of the microcontroller. The control pins (RS, R/W and EN) are connected to port P3 pins P3^0, P3^1 & P3^6 respectively.

CIRCUIT DIAGRAM

COMPONENT QUANTITY

Page 3: Lcd Based Voting Machine

1) General PCB 1

2) 16x2 LCD Display 1

3) Micro controller base 1

4) 10uf/10v capacitor 1

5) 8T89C51 micro controller 1

6) 12MHz Crystal oscillator 1

7) 10k Preset 1

8) 2 pin Switches 6

9) 7805 voltage regulator 1

10) 10k Resistor 1

COMPONENTS

KA 7805 (Voltage Regulator)

Features:

Output Current up to 1A

Output Voltage of 5

Thermal Overload Protection

Short Circuit Protection

Output Transistor Safe Operating Area Protection

Description:

7805 is a voltage regulator integrated circuit. It is a member of 78xx series of fixed linear voltage regulator ICs. The voltage source in a circuit may have fluctuations and would not give the fixed voltage output. The voltage regulator IC maintains the output voltage at a constant value. The xx in 78xx indicates the fixed

Page 4: Lcd Based Voting Machine

output voltage it is designed to provide. 7805 provides +5V regulated power supply. Capacitors of suitable values can be connected at input and output pins depending upon the respective voltage levels.

Pin Connections (Front View):

Pin Function Name

No

1 Input voltage (5V-18V) Input

2 Ground (0V) Ground

3 Regulated output; 5V (4.8V-5.2V) Output

AT89C51: AT89C51 is an 8-bit Microcontroller and belongs to Atmel's 8051 family. ATMEL 89C51 has 4KB of

Flash programmable and erasable read only memory (PEROM) and 128 bytes of RAM. It can be erased and program to a maximum of 1000 times. In 40 pin AT89C51, there are four ports designated as P1, P2, P3 and P0. All these ports are 8-bit bi-directional ports, i.e., they can be used as both input and output ports. Except P0 which needs external pull-ups, rest of the ports have internal pull-ups. When 1s are written to these port pins, they are pulled high by the internal pull-ups and can be used as inputs. These ports are also bit addressable and so their bits can also be accessed individually. Port P0 and P2 are also used to provide low byte and high byte addresses, respectively, when connected to an external memory. Port 3 has multiplexed pins for special functions like serial communication, hardware interrupts, timer inputs and read/write operation from external memory. AT89C51 has an inbuilt UART for serial communication. It can be programmed to operate at different baud rates. Including two timers & hardware interrupts, it has a total of six interrupts.

Pin Diagram:-

Page 5: Lcd Based Voting Machine

FEATURES OF 8951

1)8051 have 128 bytes of RAM

2)8051 have 128 user defined flags

3)it consist of 16 bit address bus

4)it also consist of 3 internal and two external interrupts

5)less power usage in 8051 with respect to other micro-controller

6)it consist of 16-bit program counter and data pointer

7)8051 can process 1 million one-cycle instructions per second

8)it also consist of 32 general purpose registers each of 8 bits

9)ROM on 8051 is 4 Kbytes in size

10)it also consist of Two 16 bit Timer/ Counter

LCD: LCD (Liquid Crystal Display) screen is an electronic display module and find a wide range of applications. A 16x2 LCD display is very basic module and is very commonly used in various devices and circuits. These modules are preferred over seven segments and other multi segment LEDs. The reasons being: LCDs are economical; easily programmable; have no limitation of displaying special & even custom characters (unlike in seven segments), animations and so on. A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers, namely, command and data. The command register stores the command instructions given to the LCD. A command is an instruction given to LCD to do a predefined task like initializing it, clearing its screen, setting the cursor position, controlling display etc. The data register stores

Page 6: Lcd Based Voting Machine

the data to be displayed on the LCD. The data is the ASCII value of the character to be displayed on the LCD.

Pin Diagram:-

Pin NoFunction Name

1 Ground (0V) Ground

2 Supply voltage; 5V (4.7V – 5.3V) Vcc

3 Contrast adjustment; through a variable resistor VEE

4 Selects command register when low; and data register when highRegister Select

5 Low to write to the register; High to read from the register Read/write

6 Sends data to data pins when a high to low pulse is given Enable

7 DB0

8 DB1

9 DB2

108-bit data pins

DB3

11 DB4

12 DB5

13 DB6

14 DB7

15 Backlight VCC (5V) Led+

Page 7: Lcd Based Voting Machine

16 Backlight Ground (0V) Led-

PROGRAM TO MAKE A VOTING MACHINE USING

LCD

#include<reg51.h>

#define msec 50

#define lcd_data_str_pin P2

sbit rs = P3^0; //Register select (RS)

pin sbit rw = P3^1; //Read write(RW)

pin sbit en = P3^6; //Enable(EN) pin

sbit ini_pin = P1^0; // Start voting pin

sbit stop_pin = P1^5; // Stop voting pin

sbit candidate_1=P1^1; //Candidate1

sbit candidate_2=P1^2; //Candidate2

sbit candidate_3=P1^3; //Candidate3

sbit candidate_4=P1^4; //Candidate4

int max = 0;

int carry =

0; int arr[4];

int vote_amt[3],j;

unsigned int vote_1,vote_2,vote_3,vote_4;

void delay(int delay_time) // Time delay function

{

int j,k; for(j=0;

Page 8: Lcd Based Voting Machine

j<=delay_time;j++)

for(k=0;k<=1000;k++);

}

void lcd_cmd(unsigned char cmd_addr) //Function to send command to LCD

{

lcd_data_str_pin =

cmd_addr; en = 1;

rs = 0;

rw = 0;

delay(1);

en = 0;

return;

}

void lcd_data_str(char str[50]) //Function to send string

{

int p;

for (p=0;str[p]!='\0';p++)

{

lcd_data_str_pin =

str[p]; rw = 0;

rs = 1;

en = 1;

delay(1);

en = 0;

}

return;

}

Page 9: Lcd Based Voting Machine

void lcd_data_int(unsigned int vote) //Function to send 0-9 character values

{

char dig_ctrl_var;

int p;

for (j=2;j>=0;j--)

{

vote_amt[j]=vote%10;

vote=vote/10;

}

for (p=0;p<=2;p++)

{

dig_ctrl_var = vote_amt[p]+48;

lcd_data_str_pin =

dig_ctrl_var; rw = 0;

rs = 1;

en = 1;

delay(1);

en = 0;

}

return;

}

void vote_count() // Function to count votes

{

while (candidate_1==0 && candidate_2==0 &&

candidate_3==0 && candidate_4==0); if (candidate_1==1)

{

while (candidate_1 == 1);

{

Page 10: Lcd Based Voting Machine

vote_1 = vote_1 + 1;

}

}

if (candidate_2==1)

{

while (candidate_2 == 1);

{

vote_2 = vote_2 + 1;

}

}

if (candidate_3==1)

{

while (candidate_3 == 1);

{

vote_3 = vote_3 + 1;

}

}

if (candidate_4==1)

{

while (candidate_4 == 1);

{

vote_4 = vote_4 + 1;

}

}

}

void lcd_ini()

{

lcd_cmd(0x38);

Page 11: Lcd Based Voting Machine

delay(msec);

lcd_cmd(0x0E);

delay(msec);

lcd_cmd(0x01);

delay(msec);

lcd_cmd(0x81);

delay(msec);

lcd_data_str("Welcome!!!");

delay(100);

lcd_cmd(0x01);

delay(msec);

lcd_cmd(0x80);

delay(msec);

lcd_data_str( "Press" );

delay(msec);

lcd_cmd(0x14);

delay(msec);

lcd_data_str("button");

delay(msec);

delay(msec);

lcd_cmd(0xC0);

delay(msec);

lcd_data_str("to");

delay(msec);

lcd_cmd(0x14);

delay(msec);

lcd_data_str("vote");

Page 12: Lcd Based Voting Machine

delay(100);

lcd_cmd(0x01);

delay(msec);

lcd_cmd(0x80);

delay(msec);

lcd_data_str("P1");

delay(msec);

lcd_cmd(0x84);

delay(msec);

lcd_data_str("P2");

delay(msec);

lcd_cmd(0x88);

delay(msec);

lcd_data_str("P3");

delay(msec);

lcd_cmd(0x8C);

delay(msec);

lcd_data_str("P4");

delay(msec);

vote_count();

lcd_cmd(0x01);

delay(msec);

lcd_cmd(0x85);

delay(msec);

lcd_data_str("Thank");

delay(msec);

lcd_cmd(0x14);

Page 13: Lcd Based Voting Machine

delay(msec);

lcd_data_str("You!!");

delay(100);

}

void results() // Function to show results

{

int i; carry = 0;

lcd_cmd(0x01);

delay(msec);

lcd_cmd(0x80);

delay(msec);

lcd_data_str("Results");

delay(msec);

lcd_cmd(0x14);

delay(msec);

lcd_data_str("Are");

delay(msec);

lcd_cmd(0x14);

delay(msec);

lcd_data_str("Out");

delay(msec);

lcd_cmd(0x01);

delay(msec);

lcd_cmd(0x80);

delay(msec);

lcd_data_str("P1");

delay(msec);

Page 14: Lcd Based Voting Machine

lcd_cmd(0x84);

delay(msec);

lcd_data_str("P2");

delay(msec);

lcd_cmd(0x88);

delay(msec);

lcd_data_str("P3");

delay(msec);

lcd_cmd(0x8C);

delay(msec);

lcd_data_str("P4");

delay(msec);

lcd_cmd(0xC0);

delay(100);

lcd_data_int(vote_1);

delay(msec);

lcd_cmd(0xC4);

delay(msec);

lcd_data_int(vote_2);

delay(msec);

lcd_cmd(0xC8);

delay(msec);

lcd_data_int(vote_3);

delay(msec);

lcd_cmd(0xCC);

Page 15: Lcd Based Voting Machine

delay(msec);

lcd_data_int(vote_4);

delay(300);

arr[0] = vote_1;

arr[1] = vote_2;

arr[2] = vote_3;

arr[3] = vote_4;

for( i=0; i<4; i++)

{

if(arr[i]>=max)

max = arr[i];

}

if ( (vote_1 == max) && ( vote_2 != max) && (vote_3 != max)&& (vote_4 != max) )

{

carry = 1;

lcd_cmd(0x01);

delay(msec);

lcd_cmd(0x82);

delay(msec);

lcd_data_str("Hurray!!!");

delay(50);

lcd_cmd(0xC4);

delay(msec);

lcd_data_str("P1");

delay(msec);

Page 16: Lcd Based Voting Machine

lcd_cmd(0x14);

delay(msec);

lcd_data_str("wins");

delay(msec);

}

if ( (vote_2 == max) && ( vote_1 != max) && (vote_3 != max)&& (vote_4 != max) )

{

carry = 1;

lcd_cmd(0x01);

delay(msec);

lcd_cmd(0x82);

delay(msec);

lcd_data_str("Hurray!!!");

delay(50);

lcd_cmd(0xC4);

delay(msec);

lcd_data_str("P2");

delay(msec);

lcd_cmd(0x14);

delay(msec);

lcd_data_str("wins");

delay(msec);

}

if ( (vote_3 == max) && ( vote_2 != max) && (vote_1 != max)&& (vote_4 != max) )

{

carry = 1;

lcd_cmd(0x01);

Page 17: Lcd Based Voting Machine

delay(msec);

lcd_cmd(0x82);

delay(msec);

lcd_data_str("Hurray!!!");

delay(50);

lcd_cmd(0xC4);

delay(msec);

lcd_data_str("P3");

delay(msec);

lcd_cmd(0x14);

delay(msec);

lcd_data_str("wins");

delay(msec);

}

if ( (vote_4 == max) && ( vote_2 != max) && (vote_3 != max)&& (vote_1 != max) )

{

carry = 1;

lcd_cmd(0x01);

delay(msec);

lcd_cmd(0x82);

delay(msec);

lcd_data_str("Hurray!!!");

delay(50);

lcd_cmd(0xC4);

delay(msec);

lcd_data_str("P4");

delay(msec);

Page 18: Lcd Based Voting Machine

lcd_cmd(0x14);

delay(msec);

lcd_data_str("wins");

delay(msec);

}

if (carry==0)

{

lcd_cmd(0x01);

delay(msec);

lcd_cmd(0x82);

delay(msec);

lcd_data_str("clash");

delay(50);

lcd_cmd(0x14);

delay(msec);

lcd_data_str("between!!!");

delay(50);

if(vote_2 == max)

{

lcd_cmd(0xC5);

lcd_data_str("P2");

delay(50);

}

if(vote_3 == max)

{

lcd_cmd(0xC9);

lcd_data_str("P3");

Page 19: Lcd Based Voting Machine

delay(50);

}

if(vote_4 == max)

{

lcd_cmd(0xCD);

lcd_data_str("P4");

delay(50);

}

}

}

void main()

{

ini_pin = stop_pin = 1;

vote_1 = vote_2 = vote_3 = vote_4 = 0;

candidate_1 = candidate_2 = candidate_3 = candidate_4 = 0;

lcd_cmd(0x38);

delay(msec);

lcd_cmd(0x0E);

delay(msec);

lcd_cmd(0x01);

delay(msec);

lcd_cmd(0x80);

delay(msec);

lcd_data_str( "Press" );

delay(msec);

lcd_cmd(0x14);

delay(msec);

lcd_data_str("init");

Page 20: Lcd Based Voting Machine

delay(msec);

delay(msec);

lcd_cmd(0xC0);

delay(msec);

lcd_data_str("to");

delay(msec);

lcd_cmd(0x14);

delay(msec);

lcd_data_str("begin");

delay(100);

while(1)

{

while(ini_pin != 0)

{

if (stop_pin == 0)

break;

}

if (stop_pin == 0)

{

break;

}

lcd_ini();

}

while(1)

{

results();

}

Page 21: Lcd Based Voting Machine

WORKING

The voting is started by pressing the Init switch after which the user is prompted to vote. The count of votes is stored in four 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 user’s vote.

The message stays on the screen until the next user either presses the Init button to cast another vote or Stop switch is pressed get the poll results. When the stop 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.

PCB LAYOUT

ADVANTAGES

The circuit is simple to design

Low cost

Page 22: Lcd Based Voting Machine

The device works on 5 to 18 V DC supply

Can be used for school and college level council elections.

Paper-based voting machines can actually miss ballots due to human mistakes in placing the paper-based ballot in the machine. There is also the ease of tabulating the results.

They also can provide several different languages to voters for whom English is not the first language

FUTURE SCOPE

Due to time and monetary constraints we have not been able to implement a few features in our project. This is a list of few modifications that can be made in the circuit to make it more effective.

They also can provide several different languages to voters for whom English is not the first language. There are also advantages when it comes to disabled people, such as blind individuals.

EMV's 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.

Page 23: Lcd Based Voting Machine