sms based voting machine project report

71
SMS BASED VOTING MACHINE 1 Dept. of E&C, PCE CHAPTER 1 INTRODUCTION 1.1 Introduction to SMS Based Voting Machine India is world‟s largest democracy. Fundamental right to vote or simply voting in elections forms the basis of Indian democracy. In India all earlier elections a voter used to cast his vote by using ballot paper. This is a long time-consuming process and very much prone to errors. This situation continued till election scene was completely changed by electronic voting machine. No more ballot paper, ballot boxes, stamping, etc. All this condensed into a simple box called ballot unit of the electronic voting machine. Cell phone based voting machine is capable of saving considerable printing stationery and transport of large volumes of electoral material. It is easy to transport, store, and maintain. It completely rules out the chance of invalid votes. It reduces of polling time, resulting in fewer problems in electoral preparations, law and order, candidate‟s expenditure, etc. and easy and accurate counting without any mischief at the counting centre. The aim of our project is to design & develop a mobile based voting machine. This project focuses onto implement GSM (Global System for Mobile Communication) based Voting System. This system is implemented using an embedded microcontroller. The embedded microcontroller used here is AT89S52microcontroller. Actually, the aim of the project is to implement an Automatic Voting system. GSM Based voting machine is fully controlled system. There is no chance of any mistake. Primarily, the system functions with the help of different technologies like the traditional cellular network such as Global System for Mobile Communications (GSM) and other radio frequency medium. Today GSM fitted Banks, cars; ambulances, fleets and police vehicles are common sights. The functional units of our projects are GSM MODEM, LCD display, PC data base and AT89S52. 1.2 Basic Aim of Project The aim of our project is to design & develop a mobile based voting machine. In this project user can dial the specific number from any land line or mobile phone to cast his vote. Once the user is connected to the voting machine he can enter his password & choice of vote. If

Upload: rahul-garg

Post on 08-Nov-2014

729 views

Category:

Documents


12 download

TRANSCRIPT

Page 1: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

1 Dept. of E&C, PCE

CHAPTER 1

INTRODUCTION

1.1 Introduction to SMS Based Voting Machine

India is world‟s largest democracy. Fundamental right to vote or simply voting in elections

forms the basis of Indian democracy. In India all earlier elections a voter used to cast his

vote by using ballot paper. This is a long time-consuming process and very much prone to

errors. This situation continued till election scene was completely changed by electronic

voting machine. No more ballot paper, ballot boxes, stamping, etc. All this condensed into a

simple box called ballot unit of the electronic voting machine. Cell phone based voting

machine is capable of saving considerable printing stationery and transport of large

volumes of electoral material. It is easy to transport, store, and maintain. It completely rules

out the chance of invalid votes. It reduces of polling time, resulting in fewer problems in

electoral preparations, law and order, candidate‟s expenditure, etc. and easy and accurate

counting without any mischief at the counting centre. The aim of our project is to design &

develop a mobile based voting machine.

This project focuses onto implement GSM (Global System for Mobile Communication) based

Voting System. This system is implemented using an embedded microcontroller. The embedded

microcontroller used here is AT89S52microcontroller. Actually, the aim of the project is to

implement an Automatic Voting system. GSM Based voting machine is fully controlled system.

There is no chance of any mistake. Primarily, the system functions with the help of different

technologies like the traditional cellular network such as Global System for Mobile

Communications (GSM) and other radio frequency medium. Today GSM fitted Banks, cars;

ambulances, fleets and police vehicles are common sights. The functional units of our projects

are GSM MODEM, LCD display, PC data base and AT89S52.

1.2 Basic Aim of Project

The aim of our project is to design & develop a mobile based voting machine. In this project

user can dial the specific number from any land line or mobile phone to cast his vote. Once

the user is connected to the voting machine he can enter his password & choice of vote. If

Page 2: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

2 Dept. of E&C, PCE

he has entered a valid choice & password his vote will be caste with two short duration

beeps. For invalid password/choice long beep will be generated. User is allotted 15 seconds

to enter his password & choice. A reset button is provided for resetting the system. A total

key is provided to display the result.

We have also used non-volatile memory for storing all data. EEPROM will preserve all

information in case of power failure.

1.3 Current Market Solution Available:

At present Electronic Voting Machines ("EVM") are being used in Indian General and State

Elections to implement electronic voting in part from 1999 elections and in total since 2004

elections. The EVMs reduce the time in both casting a vote and declaring the results

compared to the old paper ballot system. However, EVMs have been under a cloud of

suspicion over their alleged tamping arability and security problems during elections

(especially after the 2009 general elections). An EVM consists of two units:

• Control Unit

• Balloting Unit

The Control Unit is with the Polling Officer and the Balloting Unit is placed inside the

voting compartment

Fig 1.1: Typical Electronic Voting Machine

But EVM is very complicated and there is lot of wasting of time and money so SMS voting

machine can be a safer mode of casting vote with respect to Electronic Voting

Machines (EVM).

1.4 Current Technology Used in Project

The current technology used in the project is SMS (Short Message Service) service based

on GSM (Global System for Mobile).GSM (Global System for Mobile communications) is

an open, digital cellular technology used for transmitting mobile voice and data services.

Page 3: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

3 Dept. of E&C, PCE

GSM supports voice calls and data transfer speeds of up to 9.6 kbps, together with the

transmission of SMS (Short Message Service).

GSM operates in the 900MHz and 1.8GHz bands in Europe and the 1.9GHz and 850MHz

bands in the US. The use of harmonized spectrum across most of the globe, combined with

GSM‟s international roaming capability, allows travellers to access the same mobile

services at home and abroad. GSM enables individuals to be reached via the same mobile

number in up to 219 countries.

Terrestrial GSM networks now cover more than 90% of the world‟s population. GSM

satellite roaming has also extended service access to areas where terrestrial coverage is not

available.

Page 4: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

4 Dept. of E&C, PCE

CHAPTER 2

CIRCUIT AND BLOCK DIAGRAM OF PROJECT

2.1 Block Diagram of Project

Fig 2.1: Block Diagram of Project

2.1.1 Block Diagram Description

A mobile is interfaced to computer where database is to be verified and AT89S52

microcontroller is also interfaced to computer (PC) to display and store database. The user

has his password stored in from of his ID number in the database of PC. The User has to

send his voting information via SMS to the mobile interfaced to the microcontroller. The µc

will consider a vote if the password of a person matches to his database of software in PC.

The mobile interfaced to the PC will send an acknowledgment message when the vote is

granted, if something goes wrong then µc will send a negative acknowledgment message

via SMS to the user.

If the password of the person is entered in the same order, there will be a positive vote given

to the candidate to which the voter is voting. This is done in order to reduce the risk of

forcible voting. The PC data will be transfer to controller and further display at LCD.

2.1.2 GSM Modem

A GSM modem is a wireless modem that works with a GSM wireless network. A GSM

modem can be an external device or a PC Card PCMCIA Card. In this project GSM modem

is connected to a computer through a serial cable or a USB cable. Behaving as a PC Card .It

AT89S52

MICROCONTROLLER

PC

DATABASE

(VB)

GSM MODEM

LCD MOBILE

POWER

SUPPLY

5V

EEPROM

Page 5: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

5 Dept. of E&C, PCE

should be inserted into one of the PC Card slots of a laptop computer. Like a GSM mobile

phone, a GSM modem requires a SIM card from a wireless carrier in order to operate

computers use AT commands to control modems.

These extended AT commands are defined in the GSM standards. With the extended AT

commands Reading, writing, deleting and Sending SMS messages are monitored.

2.1.3 Mobile

Here mobile is the user mobile who‟s SIM card number has been priory registered in

voting machine. Through mobile user will have to cast his\her vote in specific format using

Short Message Service (SMS).

2.1.4 PC Database

Computer (PC) is used as common interface between microcontroller and GSM module.

Software tool visual basic 6.0 is used to control, store and secondary display of votes. In

software part two forms are made one for administration access and another for voting

status display where all options are available for storage display and control.

2.1.5 AT89S52 Microcontroller

In this project we interfaced AT89S52 microcontroller with computer and LCD. The

AT89S52 is 40 pin IC packaged in DIP package.it is derivative of 8051 family, from Atmel

AT89S52 Microcontroller is the heart of the circuit as it controls all the functions of Inc.

display, interfacing external EEPROM, LCD and computer

2.1.6 Power Supply

7805 VOLTAGE REGULATOR The 78xx (also sometimes known as LM78xx) series of devices

is a family of self-contained fixed linear voltage regulator integrated circuits. The 78xx family is a

very popular choice for many electronic circuits which require a regulated power supply, due to

their ease of use and relative cheapness. When specifying individual ICs within this family, the xx

is replaced with a two-digit number, which indicates the output voltage the particular device

is designed to provide (for example, the 7805 has a 5 volt output, while the 7812 produces 12

volts). The 78xx line is positive voltage regulators, meaning that they are designed to produce a

voltage that is positive relative to a common ground. There is a related line of 79xx devices which

are complementary negative voltage regulators. 78xx and 79xx ICs can be used in combination to

provide both positive and negative supply voltages in the same circuit, if

Page 6: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

6 Dept. of E&C, PCE

necessary.78xx ICs have three terminals and are most commonly found in the

TO220 form factor, although smaller surface- mount and larger TO3 packages are also

available from some manufacturers. These devices typically support an input voltage

which can be anywhere from a couple of volts over the intended output voltage, up to a

maximum of 35 or 40 volts, and can typically provide up to around 1 or 1.5 amps of

current .

Fig 2.2: 7805 Voltage Regulator IC

2.1.7 LCD

In this project 16*2 LCD is used. This LCD is interface with AT89S52 at port 2.It used to

display voting result with candidates A, B, C, D.

Fig 2.3: 16*2 LCD

2.1.8 Bridge Rect ifier

A diode bridge is an arrangement of four diodes in a bridge configuration that provides the

same polarity of output for either polarity of input. When used in its most common

application, for conversion of an alternating current (AC) input into direct current a (DC)

output, it is known as a bridge rectifier. A bridge rectifier provides full-wave rectification

from a two-wire AC input, resulting in lower cost and weight as compared to a rectifier with

a 3-wire input from a transformer with a center-tapped secondary winding.

Page 7: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

7 Dept. of E&C, PCE

2.2 Circuit Diagram

Fig: 2.4: Circuit Diagram

Page 8: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

8 Dept. of E&C, PCE

2.2.1 Circuit Description

Here port 1 is connected to the LCD to display data from the microcontroller to the LCD.

The virtual terminal is used to send and receive data via serial port and is used instead of a

GSM module.

The HEX file of the program is loaded into the controller and the clock frequency and baud

rates of all the devices are adjusted so that they work in synchronization. Some pins of port

3 are used to give the write and latching commands to the lcd.18th

&19th

pin is connected to

the crystal oscillator.

Twentieth pin is connected to a led which is the indicator of power supply MAX 232 is

used in this circuit for serial communication. Crystal oscillator is used for generating the

clock frequency for microcontroller. Crystal oscillator frequency for microcontroller is

11.0592MhzCapacitors in crystal oscillator is used to avoid damping.

First supply is given. The rectifier circuit converts ac power into DC. Here bridge rectifier

is used for increasing the efficiency. DC voltage generated is passed through a 7805

voltage regulator, output of which is 5volts.

Programme for voting procedure is embedded on the microcontroller Name of the

candidates appears in the lcd screen as A ,B,C,D. Then we cast the vote through the cell

phone in a prescribed format.

Page 9: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

9 Dept. of E&C, PCE

CHAPTER 3

COMPONENTS AND ITS DESCRIPTION

3.1 Component List

Basic components used in this project are:

Table 3.1 Component list

Sr.no Component Specification Quantity

1. Microcontroller (AT89S52) 1

2. LCD display 16*2 text 1

3. LED 2

4. Resistor 1K,10K 8

5. Crystal oscillator (11.0592Mhz) 1

6. Capacitor (33pf,10mf(63V),) 2

7. MAX 232 2

8. GSM module SIM300 1

9. SIM card Any 1

10. Copper clad 2

12. Voltage

regulator IC

7805 1

13. Berge strip Male Female(16 pin) 2

14. Connecting wires As per need

requirement 15. ZIF 40 pin 1

16. Resistance array 10k 1

17. Computer setup - 1

18. DB-9 Connector 9 slot 2

19. Switch On/off 1

Page 10: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

10 Dept. of E&C, PCE

3.2 Component Descriptions

3.2.1 Introduction To 8052 Microcontroller:

Fig 3.1 8052 Pin diagram

Description

The AT89S52 is a low-power, high-performance CMOS 8-bit microcomputer with 8K bytes

of Flash programmable and erasable read only memory (PEROM). The device is

manufactured using Atmel‟s high-density non-volatile memory technology and is

compatible with the industry-standard 80C51 and 80C52 instruction set and pin out. The on-

chip Flash allows the program memory to be reprogrammed in-system or by a conventional

non-volatile memory programmer. By combining a versatile 8-bit CPU with Flash on a

monolithic chip, the Atmel AT89S52 is a powerful microcomputer which provides a highly-

flexible and cost-effective solution to many embedded control applications.

Page 11: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

11 Dept. of E&C, PCE

Features of 8052:

• Compatible with MCS-51™ Products

• 8K Bytes of In-System Reprogrammable Flash Memory

• Endurance: 1,000 Write/Erase Cycles

• Fully Static Operation: 0 Hz to 24 MHz

• Three-level Program Memory Lock

• 256 x 8-bit Internal RAM

• 32 Programmable I/O Lines

• Three 16-bit Timer/Counters

• Eight Interrupt Sources

• Programmable Serial Channel

• Low-power Idle and Power-down Modes

PIN DESCRIPTION:

VCC

Supply voltage.

GND

Ground.

Port 0

Port 0 is an 8-bit open drain bi-directional I/O port. As an output port, each pin can sink

eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high

impedance inputs.

Port 0 can also be configured to be the multiplexed low order address/data bus during

accesses to external program and data memory. In this mode, P0 has internal pull-ups. Port 0

also receives the code bytes during Flash programming and outputs the code bytes during

program verification. External pull-ups are required during program verification.

Port 1

Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output buffers can

sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the

internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being

pulled low will source current (IIL) because of the internal pull-ups. In addition, P1.0 and

P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2) and the

Page 12: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

12 Dept. of E&C, PCE

timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the following table.

Port 1 also receives the low-order address bytes during Flash programming and verification.

Port 2

Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output buffers can

sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the

internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being

pulled low will source current (IIL) because of the internal pull-ups. Port 2 emits the high-

order address byte during fetches from external program memory and during accesses to

external data memory that uses 16-bit addresses (MOVX @ DPTR). In this application, Port

2 uses strong internal pull-ups when emitting 1s. During accesses to external data memory

that uses 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special

Function Register. Port 2 also receives the high-order address bits and some control signals

during Flash programming and verification.

Port 3

Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output buffers can

sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the

internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being

pulled low will source current (IIL) because of the pull-ups. Port 3 also serves the functions

of various special features of the AT89S51, as shown in the following table. Port 3 also

receives some control signals for Flash programming and verification.

Table 3.2: Port 3 description

Port Pins Alternate Function

P 3.0 RXD(serial input port)

P 3.1 TXD(serial output port)

P 3.2 INT0 (external interrupt 0)

P 3.3 INT1(external interrupt 1)

P 3.4 T0(Timer 0 external input)

P 3.5 T1(Timer 1external input)

P 3.6 WR (external data memory write strobe)

P 3.7 RD (external data memory read strobe)

Page 13: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

13 Dept. of E&C, PCE

RST

Reset input. A high on this pin for two machine cycles while the oscillator is running resets

the device.

ALE/PROG

Address Latch Enable is an output pulse for latching the low byte of the address during

accesses to external memory. This pin is also the program pulse input (PROG) during Flash

programming. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator

frequency and may be used for external timing or clocking purposes. Note, however, that

one ALE pulse is skipped during each access to external data memory. If desired, ALE

operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is

active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high.

Setting the ALE-disable bit has no effect if the microcontroller is in external execution

mode.

PSEN

Program Store Enable is the read strobe to external program memory. When the AT89S52

is executing code from external program memory, PSEN is activated twice each machine

cycle, except that two PSEN activations are skipped during each access to external data

memory.

EA/VPP

External Access Enable. EA must be strapped to GND in order to enable the device to fetch

code from external program memory locations starting at 0000H up to FFFFH. Note,

however, that if lock bit 1 is programmed, EA will be internally latched on reset EA should

be strapped to VCC for internal program executions. This pin also receives the 12-volt

programming enable voltage (VPP) during Flash programming when 12-volt programming

is selected.

XTAL1

Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL2

Output from the inverting oscillator amplifier.

Page 14: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

14 Dept. of E&C, PCE

Fig 3.2: Crystal Oscillator

Interrupts

The AT89S52 has a total of six interrupt vectors: two external interrupts (INT0 and INT1),

three timer interrupts (Timers 0, 1, and 2), and the serial port interrupt. Each of these

interrupt sources can be individually enabled or disabled by setting or clearing a bit in

Special Function Register IE. IE also contains a global disable bit, EA, which disables all

interrupts at once. In the AT89C51, bit position IE.6 and IE.5 are unimplemented. User

software should not write 1s to these bit positions, since they may be used in future AT89

products. Timer 2 interrupt is generated by the logical OR of bits TF2 and EXF2 in register

T2CON. Neither of these flags is cleared by hardware when the service routine is vectored

to. In fact, the service routine may have to determine whether it was TF2 or EXF2 that

generated the interrupt, and that bit will have to be cleared in software. The Timer 0 and

Timer 1 flags, TF0 and TF1, are set at S5P2 of the cycle in which the timers overflow. The

values are then polled by the circuitry in the next cycle. However, the Timer 2 flag, TF2, is

set at S2P2 and is polled in the same cycle in which the timer overflows.

Table 3.3: Interrupts

(MSB) (LSB)

EA - ET2 ES ET1 EX1 ET0 EX0

Enable Bit = 1 enables the interrupt.

Enable Bit = 0 disables the interrupt.

Page 15: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

15 Dept. of E&C, PCE

3.2.2 MAX 232 IC

Fig 3.3: MAX 232 IC

The MAX232 is an integrated circuit that converts signals from an RS-232 serial port to

signals suitable for use in TTL compatible digital logic circuits. The MAX232 is a dual

driver/receiver and typically converts the RX, TX, CTS and RTS signals. The drivers

provide RS- 232 voltage level outputs (approx. ± 7.5 V) from a single +5V supply via on-

chip charge pumps and external capacitors. This makes it useful for implementing RS-232

in devices that otherwise do not need any voltages outside the 0V to + 5 V range, as power

supply design does not need to be made more complicated just for driving the RS-232 in

this case. The receivers reduce RS-232inputs (which may be as high as ± 25 V), to standard

5 V TTL levels. These receivers have atypical threshold of 1.3 V, and a typical hysteresis

of 0.5 V. The later MAX232A is backwards compatible with the original MAX232 but

may operate at higher baud rates and can use smaller external capacitors ± 0.1 F in place of

the 1.0 F capacitors used with the original device. The newer MAX3232 is also backwards

compatible, but operates at a broader voltage range, from 3 to 5.5V.

The later MAX232A is backwards compatible with the original MAX232 but may operate

at higher baud rates and can use smaller external capacitors – 0.1 μF in place of the 1.0 μF

capacitors used with the original device. The newer MAX3232 is also backwards

compatible, but operates at a broader voltage range, from 3 to 5.5 V.

Pin to pin compatible: ICL232, ST232, ADM232, HIN232 (much cheaper alternatives).

Page 16: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

16 Dept. of E&C, PCE

3.2.3 GS M MODULE

Fig 3.4: GSM Module

A GS M modem is a wireless modem that works with a GSM wireless network. A

wireless modem behaves like a dial- up modem. The main difference between them is that

a dial- up modem sends and receives data through a fixed telephone line while a wireless

modem Sends and receives data through radio waves. A GSM modem can be an external

device or a PC Card PCMCIA Card. Typically, an external GSM modem is connected to

a computer through a serial cable or a USB cable. A GSM modem in the form of a PC

Card / PCMCIA Card is designed for use with a laptop computer. It should be inserted

into one of the PC Card /PCMCIA Card slots of a laptop computer. Like a GSM mobile

phone, a GSM modem requires a SIM card from a wireless carrier in order to operate.

As mentioned below of this SMS tutorial l computers use AT commands to control

modems. Both GSM modems and dial-up modems support a common set of standard AT

commands. You can use a GSM modem just like a dial- up modem. In addition to the

standard AT commands; GSM modems support an extended set of AT commands.

These extended AT commands are defined in the GSM standards. With the extended AT

commands, you can do things like:

1. Reading, writing and deleting SMS messages.

2. Sending S MS messages.

3. Monitoring the signal strength.

4. Monitoring the charging status and charge level of the battery.

5. Reading, writing and searching phone book entries.

Page 17: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

17 Dept. of E&C, PCE

The number of SMS messages that can be processed by a GSM modem per minute is very

low -- only about six to ten SMS messages per minute.

3.2.3.1 AT Commands

AT commands are instructions used to control a modem. AT is the abbreviation of

Attention. Every command l i n e starts with “AT” or “ at". That‟s why modem

commands are called AT commands. Many of the commands that are used to control

wired dial- up modems, such as ATD (Dial), ATA (Answer), ATH (Hook control) and

ATO (Return to online data state), are also supported by GSM/GP RS modems and

mobile phones. Besides this common AT command set, GS M/GPRS modems and

mobile phones support an AT command set that is specific to the GSM technology, which

includes SMS-related commands like AT+CMGS (Send SMS message), AT+CMSS (Send

SMS message from storage), AT+CMGL (List SMS messages) and AT+CMGR (Read

SMS messages).

Note that the starting "AT" is the prefix that informs the modem about the start of a

command line. It is not part of the AT command name. For example, D is the actual AT

command name in ATD and +CMGS is the actual AT command name in

AT+CMGS. However, some books and web sites use them interchangeably as the

name of an AT command.

Here are some of the tasks that can be done using AT commands with a GS M/GPRS

modem or mobile phone:

1. Get basic information about the mobile phone or GS M/GPRS modem. For

example, name of manufacturer (AT+CGMI), model number (AT+CGMM), IMEI

number (International Mobile Equipment Identity) (AT+CGSN) and software

version (AT+CGMR).

2. Get basic information about the subscriber. For example MSISDN

(AT+CNUM) and IMSI number (International Mobile Subscriber Identity)

(AT+CIMI).

3. Get the current status of the mobile phone or GSM/GP RS modem. For

example, mobile phone activity status (AT+CPAS), mobile network

registration status (AT+CREG), radio signal strength (AT+CSQ), battery charge level

Page 18: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

18 Dept. of E&C, PCE

and battery charging status (AT+C BC).

4. Establish a data connection or voice connection to a remote modem (ATD, ATA,

etc.).

5. Send and receive fax (ATD, ATA, AT+F*).

6. Send (AT+CMGS, AT+CMSS), read (AT+CMGR, AT+CMGL), write

(AT+CMGW) or delete (AT+CMGD) SMS messages and obtain notifications of newly

received SMS messages (AT+CNMI).

7. Read (AT+CP BR), write (AT+CPBW) or search (AT+CPBF) phonebook entries.

8. Perform security-related t as ks , su ch as opening or c los ing facility l o ck s

(AT+CLCK), checking whether a facility is locked (AT+CLCK) and changing

passwords (AT+CPWD). (Facility lock examples: SIM lock [a password must be

given to the SIM card every time the mobile phone is switched on] and P H-SIM lock

[a certain SIM card is associated with the mobile phone. To use other S IM cards

with the mobile phone, a password must be entered.])

9. Control the presentation of result codes / error messages of AT commands. For

example, you can control whether to enable certain error messages (AT+CMEE) and

whether error messages should be displayed in numeric format or verbose format

(AT+CMEE=1 or AT+CMEE=2).

10. Get or change the configurations of the mobile phone or GSM/GPRS modem. For example, change the GSM network (AT+COPS), bearer service type

(AT+CBS T), radio link protocol parameters (AT+CRLP), SMS center address

(AT+CSCA) and storage of SMS messages (AT+CPMS).

11. Save and restore configurations of the mobile phone or GSM/GP RS modem. For example, save (AT+CSAS) and restore (AT+CRES) settings related to

SMS messaging such as the SMS center address.

Note that mobile phone manufacturers usually do not implement all AT commands,

command parameters and parameter values in their mobile phones. Also, the behaviour of

the implemented AT commands may be different from that defined in the standard. In

general, GSM/GPRS m o d e m s designed f o r wireless applications have better

support of AT commands than ordinary mobile phones.

In addition, some AT commands require the support of mobile network operators. For

example, SMS over GP RS can be enabled on some GP RS mobile phones and GPRS

Page 19: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

19 Dept. of E&C, PCE

modems with the +CGSMS command (command name in text: Select Service for MO

SMS Messages). But if the mobile network operator does not support the transmission of

SMS over GP RS, you cannot use this features .There are two types of AT

commands: basic commands and extended commands.

Basic commands are AT commands that do not start with "+". For example, D (Dial), A

(Answer), H (Hook control) and O (Return to online data state) are basic

commands.

Extended commands are AT commands that start with "+". All GSM AT commands are

extended commands. For example, +CMGS (Send SMS message), +CMSS (Send SMS

message from storage), +CMGL (List SMS messages) and +CMGR (Read SMS messages)

are extended commands.

3.2.3.2 General Syntax of Extended AT Commands

The general syntax of extended AT commands is straightforward. The syntax rules are

provided below. The syntax of basic AT commands is slightly different. We will not

cover the syntax of basic AT commands in this SMS tutorial since all SMS

messaging commands are extended AT commands.

Syntax rule 1. All command lines must start with "AT" and end with a carriage return

character. (We will use <C R> to represent a carriage return character in this SMS

tutorial.) In a terminal program like HyperTerminal of Microsoft Windows, you can press

the Enter key on the keyboard to output a carriage return character.

Example: To list all unread inbound SMS messages stored in the message storage area,

type "AT", then the extended AT command "+CMGL", and finally a carriage return

character, like this:

AT+CMGL<CR>

Syntax rule 2. A command line can contain more than one AT command. Only the first

AT command should be prefixed with "AT". AT commands in the same command- line

string should be separated with semicolons.

Example: To list all unread inbound SMS messages stored in the message storage area and

obtain the manufacturer name of the mobile device, type "AT", then the extended AT

command "+CMGL", followed by a semicolon and the next extended AT

command "+CGMI":

AT+CMGL; +CGMI<CR>

Page 20: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

20 Dept. of E&C, PCE

An error will occur if both AT commands are prefixed with "AT", like this:

AT+CMGL; AT+C GMI<CR>

Syntax rule 3. A string is enclosed between double quotes.

Example: To read all SMS messages from message storage in SMS text mode (at this time

you do not need to know what SMS text mode is. More information will be provided later

in this SMS tutorial), you need to assign the string "ALL" to the extended AT

command +CMGL, like this:

AT+CMGL="ALL"<CR>

Syntax rule 4. Information responses and result codes (including both final result

codes and unsolicited result codes) always start and end with a carriage return

character and a linefeed character.

Example: After sending the command line "AT+CGMI<CR>“to the mobile device, the

mobile device should return a response similar to this:

The first line is the information response of the AT command +CGMI and the second line

is the final result code. <C R> and <LF> represent a carriage return character and a line

feed character respectively. The final results c o d e "OK” marks the end of the

response. It indicates no more data will be sent from the mobile device to the

computer / PC.

When a terminal program such as HyperTerminal of Microsoft Windows sees a

carriage return character, it moves the cursor to the beginning of the current line.

When it sees a linefeed character, it moves the cursor to the same position on the next line.

Hence, the command line "AT+CGMI<CR> " that you entered and the

corresponding response will be displayed like this in a terminal program such as

HyperTerminal of Microsoft Windows:

AT+C GMI

Nokia

OK

3.2.3.3 Information Response and Final Result Code

Don't forget the meanings of information response and final result code stated above,

since you will see these two terms frequently as you go through this SMS tutorial.

Page 21: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

21 Dept. of E&C, PCE

Result codes of AT commands: Result codes are messages sent from the GSM/GP RS

modem or mobile phone to provide you information about the execution of an AT

command and the occurrence of an event. Two types of result codes are useful to you

when dealing with AT commands for SMS messaging:

Final result codes

Unsolicited result codes

Final Result Codes of AT Commands: A final result code marks the end of an AT

command response. It is an indication that the GSM/GP RS modem or mobile phone has

finished the execution of a command line. Two frequently used final result codes are OK

and ERRO R. Only one final result code will be returned for each command line. Thus, you

will not see both OK and ERROR in the response of a command line.

The OK Final Result Code: The OK final result code indicates that a command

line has been executed successfully by the GSM/GP RS modem or mobile phone. It

always starts and ends with a carriage return character and a linefeed character.

Here is an example for illustration. Let's say you send the command line "AT+CMGL;

+CGMI<C R>“to your GSM/GPRS modem. The AT c o m m a n d "+CMGL" is

used to list SMS messages stored in the message storage area and the AT command

“+CGMI" is used to get the manufacturer name of the GS M/GPRS modem. If

everything works properly without any errors, the command line, together with the

response returned, should be something similar to this:

AT+CMGL; +CGMI<CR>

<CR><LF>+CMGL: 1,"REC UNREAD","+85291234567",”06/11/11, 00:30:29+32"<C

R><LF>Welcome to our SMS tutorial. <CR><LF> <CR><LF> Nokia

<CR><LF><CR><LF>OK<CR><LF>

As mentioned earlier, when a terminal program such as HyperTerminal of Microsoft

Windows sees a carriage return character, it moves the cursor to the beginning of the

current line. When it sees a linefeed character, it moves the cursor to the same

position on the next line. Hence, the command line you entered, together with the

response returned, will be displayed like this in a terminal program such as

HyperTerminal of Microsoft Windows:

AT+CMGL; +CGMI

Page 22: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

22 Dept. of E&C, PCE

+CMGL: 1,"REC UNREAD","+7568501753",”06/11/11, 00:30:29+32" Welcome to our

SMS tutorial”.

Nokia

OK

3.2.3.4 SMS Tutorial

In general, there are two ways to send SMS messages from a computer / PC to a

mobile phone:

1. Connect a mobile phone or GSM/GPRS modem to a computer / PC. Then use the

computer / PC and AT commands to instruct the mobile phone or GSM/GPRS modem to

send SMS messages.

2. Connect the computer / PC to the SMS center (SMSC) or SMS gateway of a wireless

carrier or SMS service provider. Then send SMS messages using a protocol / interface

supported by the S MSC or SMS gateway.

3.2.3.5 The 1st Way: Sending S MS Messages from a Computer Using a Mobile

P hone or GSM/GP RS Modem

The SMS specification has defined a way for a computer to send SMS messages

through a mobile phone or GS M/GPRS modem. A GSM/GP RS modem is a wireless

modem that works with GS M/GPRS wireless networks. A wireless modem is similar to a

dial-up modem. The main difference is that a wireless modem transmits data through a

wireless network whereas a dial-up modem transmits data through a copper telephone line.

Most mobile phones can be used as a wireless modem. However, some mobile phones have

certain limitations comparing to GSM/GPRS modems.

To send SMS messages, first place a valid SIM card from a wireless carrier into a mobile

phone or GSM/GP RS modem, which is then connected to a computer. There are several

ways to connect a mobile phone or GSM/GP RS modem to a computer. For example, they

can be connected through a serial cable, a USB cable, a Bluetooth link or an infrared link.

The actual way to use depends on the capability of the mobile phone or GSM/GP RS

modem. For example, if a mobile phone does not support Bluetooth, it cannot connect

to the computer through a Bluetooth link.

After connecting a mobile phone or GSM/GP RS modem to a computer, you can

Page 23: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

23 Dept. of E&C, PCE

control the mobile phone or GSM/GP RS modem by sending instructions to it. The

instructions used for controlling the mobile phone or GS M/GPRS modem are called AT

commands. (AT commands are also used to control dial- up modems for wired

telephone system.) Dial- up modems, mobile phones and GSM/GP RS modems support a

common set of standard AT commands. In addition to this common set of standard AT

commands, mobile phones and GSM/GP RS modems support an extended set of AT

commands. One use of the extended AT commands is to control the sending and

receiving of SMS messages.

The following table lists the AT commands that are related to the writing and sending of

SMS messages:

Table 3.4: AT Command TX

AT command Meaning

+CMGS Send message

+CMSS Send message from storage

+CMGW Write message to memory

+CMGD Delete message

+CMGC Send command

+CMMS More messages to send

One way to send AT commands to a mobile phone or GSM/GP RS modem is to use a

terminal program. A terminal program's function is like this: It sends the character you

typed to the mobile phone or GSM/GP RS modem. It then displays the response it receives

from the mobile phone or GSM/GPRS modem on the screen. The terminal program on

Microsoft Windows is called HyperTerminal. Below shows a simple example that

demonstrates how to use AT commands and the HyperTerminal program of

Microsoft Windows to send an SMS text message. The lines in bold type are the

command lines that should be entered in HyperTerminal. The other lines are responses

returned from the GSM / GP RS modem or mobile phone.

Page 24: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

24 Dept. of E&C, PCE

AT OK AT+CMGF=1

OK

AT+CMGW="+7568501753"> A simple demo of SMS text messaging.

+CMGW:

OK

AT+CMSS=1

+CMSS:

OK

To send SMS messages from an application, you have to write the source code for

connecting to and sending AT commands to the mobile phone or GS M/GPRS

modem, just like what a terminal program does. You can write the source code in C,

C++, Java, Visual Basic, Delphi or other programming languages you like. However,

writing your own code has a few disadvantages:

1. You have to learn how to compose the bits and bytes of an SMS message. For

example, to specify the character encoding (e.g. 7-bit encoding and 16-bit Unicode

encoding) of an SMS message, you need to know which bits in the message header

should be modified and what value should be assigned.

2. Sending SMS messages with a mobile phone or GSM/GP RS modem has a

drawback -- the SMS transmission speed is low. As your SMS messaging

application becomes more popular, it has to handle a larger amount of SMS traffic

and finally the mobile phone or GSM/GPRS modem will not be able to take the load.

To obtain a high SMS transmission speed, a direct connection to an SMSC or S MS

gateway of a wireless carrier or S MS service provider is needed. However, AT

commands are not used for communicating with an SMS center or SMS gateway.

This means you have to make a big change to your SMS messaging application in

order to move from a wireless- modem- based solution to a SMSC-based solution.

In most cases, instead of writing your own code for interacting with the mobile phone or

GSM/GPRS modem via AT commands, a better solution is to use a high- level SMS

messaging API (Application programming interface) / S DK (Software

development kit) / library. The AP I / SDK / library encapsulates the low- level details. So,

an SMS application developer does not need to know AT commands and the

composition of S MS messages in the bit-level. Some SMS messaging APIs / S DKs /

libraries support SMSC protocols in addition to AT commands. To move from a

Page 25: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

25 Dept. of E&C, PCE

wireless- modem-based SMS solution to a SMSC-based SMS solution, usually you just

need to modify a configuration file / property file or make a few changes to your SMS

messaging application's source code.

Another way to hide the low-level AT command layer is to place an SMS gateway

between the SMS messaging application and the mobile phone or GS M/GPRS

modem. (This has been described in the section "What is an SMS Gate way?” earlier.)

Simple protocols such as HTTP / HTTPS can then be used for sending S MS messages in

the application. If an SMSC protocol (e.g. SMPP, CIMD, etc.) is used for

communicating with the SMS gateway instead of HTTP / HTTPS, an SMS messaging API

/ S DK / library can be very helpful to you since it encapsulates the SMSC protocol's

details.

Usually a list of supported / unsupported mobile phones or wireless modems is

provided on the web site of an SMS messaging API / SDK / library or an SMS

gateway software package. Remember to check the list if you are going to use an

SMS messaging API / SDK / library or an S MS gateway software package.

3.2.3.6 How to receive SMS messages using Computer/PC

In general, there are three ways to receive SMS messages using your computer / PC:

1. Connect a mobile phone or GSM/GPRS modem to a computer / PC. Then use the

computer / PC and AT commands to get the received SMS messages from the mobile

phone or GSM/GP RS modem.

2. Get access to the SMS center (SMSC) or SMS gateway of a wireless carrier.

Any SMS messages received will be forwarded to your computer / PC using a protocol

/ interface supported by the S MSC or SMS gateway.

3. Get access to the SMS gateway of an SMS service provider. Any SMS messages

received will be forwarded to your computer / PC using a protocol / interface supported

by the SMS gateway.

3.2.3.7 The 1st Way: Using a Computer to Receive SMS Messages through a Mobile Phone

or GSM/GP RS Modem

Receiving SMS messages through a mobile phone or GSM/GP RS modem has a major

advantage over the other two ways -- wireless carriers usually do not charge any fees for

receiving incoming SMS messages with their SIM cards. The disadvantage of receiving

SMS messages this way is that a mobile phone or GSM/GP RS modem cannot handle

Page 26: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

26 Dept. of E&C, PCE

a large amount of SMS traffic. One way to overcome this is to load balance the S MS

traffic with a pool of mobile phones or GSM/GP RS modems. Each mobile phone or GS

M/GPRS modem will have its own SIM card and mobile phone number.

In terms of programming, sending and receiving SMS messages through a mobile

phone or GSM/GP RS modem are similar. What you need to do is to send instructions (in

the form of AT commands) to the mobile phone or GSM/GP RS modem.

The following table lists the AT commands that are related to the receiving and

reading of SMS messages:

Table 3.5: AT Command RX

AT command Meaning

+CNMI New message indications

+CMGL List messages

+CMGR Read messages

+CNMA New message acknowledgement

Below shows a simple example that demonstrates how to use AT commands and the

HyperTerminal program of Microsoft Windows to read SMS text messages received by

a GSM / GP RS modem or mobile phone. The lines in bold type are the command lines

that should be entered in HyperTerminal. The other lines are responses returned from the

GSM / GP RS modem or mobile phone.

AT OK AT+CMGF=1

OK

AT+CMGL=" ALL"

+CMGL: 1,"REC READ","+7568501753",”06/11/11, 00:30:29+32" Hello, welcome to

our SMS tutorial.

+CMGL: 2,"REC READ","+7568501753",”06/11/11, 00:32:20+32" A simple

demo of SMS text messaging.

OK

Page 27: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

27 Dept. of E&C, PCE

3.2.4 LCD

Fig 3.5: LCD 16*2

An HD44780 Character LCD is a de facto industry standard liquid crystal display

(LCD) display device designed for interfacing with embedded systems. These screens

come in a variety of configurations including 8x1, which is one row of eight

characters, 16x2, and 20x4. The most commonly manufactured configuration is 40x4

characters, which requires two individually addressable HD44780 controllers with

expansion chips as the HD44780 can only address up to 80 characters. These LCD

screens are limited to text only and are often used in copiers, fax machines, laser

printers, industrial test equipment, networking equipment such as routers and storage

devices. Character LCDs use a standard 14-pin interface and those with backlights have

16 pins. The pin outs are as follows:

1. Ground

2. VCC (+3.3 to +5V)

3. Contrast adjustment (VO)

4. Register Select (RS). RS=0: Command, RS=1: Data

5. Read/Write (R/W). R/W=0: Write, R/W=1: Read

6. Clock (Enable). Falling edge triggered

7. Bit 0 (Not used in 4-bit operation)

8. Bit 1 (Not used in 4-bit operation)

9. Bit 2 (Not used in 4-bit operation)

10. Bit 3 (Not used in 4-bit operation)

11. Bit 4

12. Bit 5

Page 28: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

28 Dept. of E&C, PCE

13. Bit 6

14. Bit 7

15. Backlight Anode (+)

16. Backlight Cathode (-)

Character LCDs can operate in 4-bit or 8-bit mode. In 4 bit mode, pins 7 through 10

are unused and the entire byte is sent to the screen using pins 11 through 14 by

sending 4-bits (nibble) at a time.

3.3 ATMEL 24C02 Flash Memory

Features

• Low-voltage and Standard-voltage Operation.

– 2.7 (VCC = 2.7V to 5.5V)

– 1.8 (VCC = 1.8V to 5.5V)

• Internally Organized 128 x 8 (1K), 256 x 8 (2K), 512 x 8 (4K),

1024 x 8 (8K) or 2048 x 8 (16K).

• Two-wire Serial Interface.

• Schmitt Trigger, Filtered Inputs for Noise Suppression.

• Bidirectional Data Transfer Protocol.

• 100 kHz (1.8V) and 400 kHz (2.7V, 5V) Compatibility.

• Write Protect Pin for Hardware Data Protection.

• 8-byte Page (1K, 2K), 16-byte Page (4K, 8K, 16K) Write Modes.

• Partial Page Writes Allowed.

• Self-timed Write Cycle (5 ms max).

• High-reliability

– Endurance: 1 Million Write Cycles

– Data Retention: 100 Years

• Automotive Devices Available.

• 8-lead JEDEC PDIP, 8-lead JEDEC SOIC, 8-lead Ultra-Thin Mini-MAP (MLP 2x3),

5- Lead SOT23, 8-lead TSSOP and 8-ball dBGA2 Packages.

• Die Sales: Wafer Form, Waffle Pack and Bumped Wafers.

Page 29: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

29 Dept. of E&C, PCE

Description

The AT24C01A/02/04/08A/16A provides 1024/2048/4096/8192/16384 bits of serial

electrically erasable and programmable read-only memory (EEPROM) organized as

128/256/512/1024/2048 words of 8 bits each. The device is optimized for use in many

industrial and commercial applications where low-power and low-voltage operation are

essential. The AT24C01A/02/04/08A/16A is available in space-saving 8-lead PDIP, 8-lead

JEDEC SOIC, 8-lead Ultra-Thin Mini-MAP (MLP 2x3), 5-lead SOT23

(AT24C01A/AT24C02/AT24C04), 8-lead TSSOP, and 8-ball dBGA2 packages and is

accessed via a Two-wire serial interface. In addition, the entire family is available in 2.7V

(2.7V to 5.5V) and 1.8V (1.8V to 5.5V) versions.

PIN Diagram

Table 3.6: Pin configuration of ATMEL 24C02

Page 30: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

30 Dept. of E&C, PCE

CHAPTER 4

DATABASE

In this project the database of voting is maintained though software tool Visual basics 6.0

In this software tool there is full duplex interfacing between microcontroller, PC and GSM

module.

4.1 Introductions to Visual Basics

Visual Basic is a third-generation event-driven programming language and integrated

development environment (IDE) from Microsoft for its COM programming model first

released in 1991. Visual Basic is designed to be relatively easy to learn and use. Visual

Basic was derived from BASIC and enables the rapid application development

(RAD) of graphical user interface (GUI) applications, access to databases using Data

Access Objects, Remote Data Objects, or ActiveX Data Objects, and creation

of ActiveX controls and objects. VBA is effectively the same language as Visual Basic but

VBA-code is tied to Microsoft Office and can only run within that environment.

The scripting language VBScript is a subset of Visual Basic.

A programmer can create an application using the components provided by the Visual Basic

program itself. Programs written in Visual Basic can also use the Windows API, but doing

so requires external function declarations. Though the program has received criticism for its

perceived faults, version 3 of Visual Basic was a runaway commercial success, and many

companies offered third party controls greatly extending its functionality.

The final release was version 6 in 1998. Microsoft's extended support ended in March 2008

and the designated successor was Visual Basic .NET (now known simply as Visual Basic).

4.1.1 Language Features of Visual Basic 6.0

Like the BASIC programming language, Visual Basic was designed to be easily learned and

used by beginner programmers. The language not only allows programmers to create

simple GUI applications, but to also develop complex applications. Programming in VB is a

combination of visually arranging components or controls on a form, specifying attributes

Page 31: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

31 Dept. of E&C, PCE

Fig 4.1: Icons for main controls in Visual Basic

6.0

and actions of those components, and writing additional lines of code for more

functionality. Since default attributes and actions are defined for the components, a simple

program can be created without the programmer having to write many lines of code.

Performance problems were experienced by earlier versions, but with faster computers and

native code compilation this has become less of an issue.

Although VB programs can be compiled into native code executables from version 5

onwards, they still require the presence of runtime libraries of approximately 1 MB in size.

Runtime libraries are included by default in Windows 2000and later, however for earlier

versions of Windows, i.e. 95/98/NT, runtime libraries must be distributed together with the

executable.

Fig 4.2: An empty form in Visual Basic 6.0

Forms are created using drag-and-drop techniques. A tool is used to place controls (e.g., text

boxes, buttons, etc.) on the form (window). Controls have attributes and event

Page 32: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

32 Dept. of E&C, PCE

handlers associated with them. Default values are provided when the control is created, but

may be changed by the programmer. Many attribute values can be modified during run time

based on user actions or changes in the environment, providing a dynamic application. For

example, code can be inserted into the form resize event handler to reposition a control so

that it remains centered on the form, expands to fill up the form, etc. By inserting code into

the event handler for a key press in a text box, the program can automatically translate the

case of the text being entered, or even prevent certain characters from being inserted. Visual

Basic can create executable (EXE files), ActiveX controls, or DLL files, but is primarily

used to develop Windows applications and to interface database systems. Dialog boxes with

less functionality can be used to provide pop-up capabilities. Controls provide the basic

functionality of the application, while programmers can insert additional logic within the

appropriate event handlers. For example, a drop-down combination box will automatically

display its list and allow the user to select any element. An event handler is called when an

item is selected, which can then execute additional code created by the programmer to

perform some action based on which element was selected, such as populating a related list.

Alternatively, a Visual Basic component can have no user interface, and instead provide

ActiveX objects to other programs via Component Object Model (COM). This allows

for server-side processing or an add-in module. The runtime recovers unused memory

using reference counting which depends on variables passing out of scope or being set to

"Nothing", resulting in the very common problem of memory leaks. There is a large library

of utility objects, and the language provides basic object oriented support. Unlike many

other programming languages, Visual Basic is generally not case sensitive, although it will

transform keywords into a standard case configuration and force the case of variable names

to conform to the case of the entry within the symbol table. String comparisons are case

sensitive by default.

The Visual Basic compiler is shared with other Visual Studio languages (C, C++), but

restrictions in the IDE do not allow the creation of some targets (Windows model DLLs)

and threading models.

Page 33: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

33 Dept. of E&C, PCE

4.2 Characteristics of Visual Basic 6.0

Visual Basic has the following traits which differ from C-derived languages:

Statements tend to be terminated with keywords such as "End If", instead of using ""s

to group statements.

Multiple variable assignments are not possible. A = B = C does not imply that the

values of A, B and C are equal. The Boolean result of "Is B = C?" is stored in A. The

result stored in A would therefore be either false or true.

Boolean constant True has numeric value −1. This is because the Boolean data type is

stored as a 16-bit signed integer. In this construct −1 evaluates to 16 binary 1s (the

Boolean value True), and 0 as 16 0s (the Boolean value False). This is apparent when

performing a Not operation on a 16 bit signed integer value 0 which will return the

integer value −1, in other words True = Not False. This inherent functionality becomes

especially useful when performing logical operations on the individual bits of an integer

such as And, Or, Xor and Not. This definition of True is also consistent with BASIC

since the early 1970s Microsoft BASIC implementation and is also related to the

characteristics of CPU instructions at the time.

Logical and bitwise operators are unified. This is unlike some C-derived languages

(such as Perl), which have separate logical and bitwise operators. This again is a

traditional feature of BASIC.

Variable array base. Arrays are declared by specifying the upper and lower bounds in a

way similar to Pascal and FORTRAN. It is also possible to use the Option Base

statement to set the default lower bound. Use of the Option Base statement can lead to

confusion when reading Visual Basic code and is best avoided by always explicitly

specifying the lower bound of the array. This lower bound is not limited to 0 or 1,

because it can also be set by declaration. In this way, both the lower and upper bounds

are programmable. In more subscript-limited languages, the lower bound of the array is

not variable. This uncommon trait does exist in Visual Basic .NET but not in VBScript.

OPTION BASE was introduced by ANSI, with the standard for ANSI Minimal BASIC

in the late 1970s.

Page 34: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

34 Dept. of E&C, PCE

Relatively strong integration with the Windows operating system and

the Component Object Model. The native types for strings and arrays are the

dedicated COM types, BSTR and SAFEARRAY.

Banker's rounding as the default behaviour when converting real numbers to integers

with the Round function.[7]

? Round (2.5, 0) gives 2,? Round(3.5, 0) gives 4.

Integers are automatically promoted to real‟s in expressions involving the normal

division operator (/) so that division of one integer by another produces the

intuitively correct result. There is a specific integer divide operator (\) which does

truncate.

By default, if a variable has not been declared or if no type declaration character is

specified, the variable is of type Variant. However this can be changed with Deftype

statements such as DefInt, DefBool , DefVar, DefObj, DefStr. There are

12 Deftype statements in total offered by Visual Basic 6.0. The default type may be

overridden for a specific declaration by using a special suffix character on the

variable name (# for Double, for Single, & for Long, % for Integer, $ for String,

and @ for Currency) or using the key phrase as (type). VB can also be set in a mode

that only explicitly declared variables can be used with the command Option

Explicit.

With VB 6, you can create any program depending on your objective. For example,

if you are a college or university lecturer, you can create educational programs to

teach business, economics, engineering, computer science, accountancy, financial

management, information system and more to make teaching more effective and

interesting. If you are in business, you can also create business programs such as

inventory management system, point-of-sale system, payroll system, financial

program as well as accounting program to help manage your business and increase

productivity. For those of you who like games and working as games programmer,

you can create those programs as well. Indeed, there is no limit to what program

you can create! There are many such programs in this tutorial, so you must spend

more time on the tutorial in order to learn how to create those programs.

4.3 Project Database Features

In this project two forms are created form 1 for administration login and form 2 for main

database window.

Page 35: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

35 Dept. of E&C, PCE

4.3.1 Form 1

Fig: 4.3: form1

Form 1 include two text windows one for user name and another for password. Two buttons

are provided for ok to submit username and password and exit button for exit. If the

password entered by admin is correct then only form 2 will be displayed.

4.3.2 Form 2

Form 2 is the main window of voting machine in software part for display, control and

storage of database.

4.3.2.1 Form 2 description

a) GSM MODEM COMMUNICATION: This label consist two buttons Start and Stop ,

the Start button is for starting modem .as we click start button at commands are

implemented at modem and whenever there is network available ok command is display at

GSM MOEM DATA text window. The stop button is to stop the modem.

b) MICROCONTROLLER COMMUNICATION: This label consist two buttons Start

and Stop , the Start button is for starting microcontroller .as we click start button voting

status is send to microcontroller and displayed on lcd. The stop button is to stop the

controller.

Page 36: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

36 Dept. of E&C, PCE

Fig 4.4: Form 2 before Voting

c) Voter's Detail: In this text window voting detail of user (voter) is displayed.in the details

voter NAME, PHONE NO. and CHOICE is displayed.

d) Erase Button: It will erase the data store in EEPROM.

e) Overall Voting: It will display the overall voting status from EEPROM.

f) Send Data: It will send data to EEPROM and microcontroller.

g) Logout: It will save current voting status and exit from window.

Page 37: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

37 Dept. of E&C, PCE

Fig 4.5: Form 2 after Voting

Page 38: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

38 Dept. of E&C, PCE

CHAPTER 5

LAYOUT & PCB DESIGNING

5.1 Printed Circuit Board (PCB)

A printed circuit board, or PCB, is used to mechanically support and electrically

connect electronic components using conductive pathways, tracks or signal

traces etched from copper sheets laminated onto a non-conductive substrate. When the

board has only copper tracks and features, and no circuit elements such as capacitors,

resistors or active devices have been manufactured into the actual substrate of the board, it

is more correctly referred to as printed wiring board (PWB) or etched wiring board. Use of

the term PWB or printed wiring board although more accurate and distinct from what would

be known as a true printed circuit board, has generally fallen by the wayside for many

people as the distinction between circuit and wiring has become blurred. Today printed

wiring (circuit) boards are used in virtually all but the simplest commercially produced

electronic devices, and allow fully automated assembly processes that were not possible or

practical in earlier era tag type circuit assembly processes.

5.2 Advantages of PCB

Advantages of PCBs are:

a) The circuit board fabrication cost (PCB cost) is lower with mass quantity production

b) Electronic circuit characteristics will be maintained without introducing parasite

capacitance with a proper circuit board design.

c) Component wiring and assembly can be mechanized in a circuit board manufacturing

facility.

d) PCB‟s offer uniformity of electrical characteristics from assembly to assembly.

e) The location of electronic parts is fixed and so it simplifies components identification

and maintenance of equipment.

f) Inspection time is reduced because printed circuitry eliminates the probability of error.

Page 39: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

39 Dept. of E&C, PCE

5.3 PCB Layout

Fig 5.1: Top layer

Page 40: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

40 Dept. of E&C, PCE

Fig 5.2: Bottom layer

Page 41: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

41 Dept. of E&C, PCE

CHAPTER 6

SOFTWARE & HARDWARE TOOL

6.1 Software Tools:

6.1.1 Keil Uvision 4.0

Keil Software is used provide you with software development tools for 8051 based

microcontrollers. With the Keil tools, you can generate embedded applications for

virtually every 8051 derivative. The supported microcontrollers are listed in the μ- vision

6.1.2 Proteus Professional V7.6

Proteus is software fo r microprocessor simulation, schematic capture, and printed

circuit board (PCB) design. It is developed by Lab center Electronics.

The X Game Station Micro Edition was designed using Lab center‟s Proteus schematic

entry and PCB layout tools.

6.1.3 Programming language

The programming language used in this project is “C language”.

6.2 Hardware Tools:

DB 9 Connector: The DB9 (originally DE-9) connector is an analog 9-pin plug of the D-

Sub miniature connector family (D-Sub or Sub-D).The DB9 connector is mainly used for

serial connections, allowing for the asynchronous transmission of data as provided for by

standard RS-232 (RS-232C).

Fig 6.1:DB9 Connector

Note that there are DB9-DB25 adapters for easily converting a DB9 plug into a DB25, and

vice versa.

Page 42: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

42 Dept. of E&C, PCE

CHAPTER 7

FLOW CHART AND ALGORITHMS

7.1 Flow Chart of Project

Fig 7.1: Flow Chart of Project

Page 43: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

43 Dept. of E&C, PCE

7.2 Algorithms of Microcontroller Programming

STEP1: INITIALIZING SYSTEM VARIABLE: PORT 1

STEP 2: INITIALIZING LCD

STEP 3: DATA WRITING OF THE LCD

STEP 4: CHECKING MSB BIT IS '0' OR'1' USED FOR SENDING THE BIT

STEP 5: RESET IN_DATA

STEP 6: PROVING DELAY FOR RECEVING SIGNALS

STEP 7: RCEIVING DATA FROM PC

STEP 8: SAVIN DATA IN EEPROM

STEP 9: READING DATA FROM PC

STEP 10: TRASMISSION DATA FROM MEMORY TO PC DATABASE

7.3 Algorithms of Visual Basic Programming

STEP1: INITIALIZING SYSTEM VARIABLE

STEP 2: INITIALIZING GSM MODEM

STEP 3: INITIALIZING MICROCONTROLLER

STEP 4: CHECKING USERNAME AND PASSWORD IN SMS FORMAT

STEP 5: UPDATING CANDIDATE CHOICE

STEP 6: EXTRACTING MOBILE NUMBER NAME AND CHOICE FROM SMS

STEP 7: SENDING DATA TO MICROCONTROLLER

STEP 8: SAVING DATA IN MEMORY.

Page 44: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

44 Dept. of E&C, PCE

CHAPTER 8

ADVANTAGES & APPLICATIONS

8.1 Applications

a) The EVM system is a longtime-consuming process and very much prone to errors.

b) This situation continued till election scene was completely changed by electronic

voting machine.. Cell phone based voting machine is capable of saving considerable

printing stationery and transport of large volumes of electoral material.

c) SMS based voting system can be used in remote areas where manual voting system

is difficult to implement.

d) This system can be used in colleges, society and various other places for elections.

e) Fast track voting which could be used in small scale elections, like resident welfare

association, “panchayat” level election and other society level elections.

f) It could also be used to conduct opinion polls during annual shareholders meeting.

g) It could also be used to conduct general assembly elections where number of

candidates are less than or equal to eight in the current situation.

h) It is used in various TV serials as for public opinion.

8.2 Advantages

a) Democracy: All and only the authorized voters can vote, and each eligible voter can

vote no more than once. Voters can also choose not to vote.

b) Privacy: All votes remain secret while voting takes place and each individual vote

cannot be linked by any individual or authority to the voter who casts it.

c) Accuracy: The voting result accurately reflects voters· Choices. In this case, no vote

can be altered, duplicated or eliminated without being detected.

d) Fairness: No partial result is available before the final result comes out.

Page 45: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

45 Dept. of E&C, PCE

CHAPTER 9

FUTURE SCOPE & LIMITATIONS

9.1 Future Scope

The system can be further modified to enhance its utility. The enhancements are:

a) Number of candidates could be increased.

b) It can be interfaced with printer to get the hard copy of the result almost instantly

from the machine itself.

c) It can also be interfaced with the personal computer and result can be stored in the

central server.

d) Once the result is on the server it could be relayed on the network to various offices

of the election conducting authority. Thus our project can make results available at

any corner of the world in a matter of seconds.

9.2 Limitations

a) Number of candidates is less.

b) Major limitation is network problem.

c) Less storage of data.

d) Voting numbers are limited to three digits.

Page 46: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

46 Dept. of E&C, PCE

CHAPTER 10

CONCLUSION

We proposed a GSM mobile voting scheme, where the GSM authentication Infrastructure is

used to provide voter authentication and improve voter mobility. Authentication is always a

difficult requirement to fulfil for remote voting schemes, most of which apply a public-key

based signature scheme for voter authentication. In our scheme, by using the existing GSM

authentication infrastructure, the public-key overhead is largely reduced. Our scheme also

enhances the security and provides more mobility and convenience to voters. Where the

voters‟ privacy is protected by applying a blind signature scheme. In this report, we

presented the basic structure and protocol of our GSM based mobile voting system.

Page 47: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

47 Dept. of E&C, PCE

REFERENCES / BIBLIOGRAPHY

Muhammad Ali Mazidi , Janice Gillispie Mazidi, Rolin D. Mckinlay.

Second edition, “THE 8051 MICROCONTROLLER AND EMBEDDED

SYSTEM”

K. J. Ayala. Third edition, “The 8051 MICROCONTROLLER”

Tutorial on microcontroller:

www.8051projects.net/microcontroller_tutorials/

Tutorial on LCD:

www.8051projects.net/lcd-interfacing/

WEBSITES

www.atmel.com

www.howstuffworks.com

www.alldatasheets.com

www.efyprojects.com

www.google.com

Page 48: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

48 Dept. of E&C, PCE

APPENDICES / ANNEXURE

A.1 Electronic Component Cost

SR.NO COMPONENT NAME REFRENCE

NUMBER

QUANTITY RATE

PER

UNIT

AMOUNT

1. MICROCONTROLLER AT89S52 1 55.00 55.00

2. GSM MODULE SIM 300 1 3000.0 3000.0

3. MAX232 16PIN 2 20.00 40.00

4. REGULATOR IC LM7805 1 7.00 7.00

5. LED RED

GREEN

1

1

2.00 4.00

6. COPPERCLADE PCB 2 35.00 70.00

7. CAPACITOR 10µF,16V

22pF

2

2

1.50

1.50

3

3

8. CRYSTAL

OSSCILLATOR

11.0592MHZ 1 7.00 7.00

9. IC BASE 40 PIN 1 4.00 4.00

10. SOLDERING WIRE 15METER 1 10.00 150.00

11. DB9 CONNECTOR 9 PIN 2

231.0

464.0

Page 49: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

49 Dept. of E&C, PCE

A.2 Mechanical Structure Cost

Total cost of project (Electronic + Mechanical components) =4123/-

12. RESISTERS 10KΩ

1KΩ

220Ω

310KΩ

1

1

1

1

1.00

1.00

1.00

1.00

4.00

13. EEPROM 24C02 1 21.00 21.00

14. TRANSISTOR 2N3904 1 8.00 8.00

15. BATTERY +9V 1 38.00 38.00

16. TRANSFORMER +12V 1 45.00 45.00

TOTAL: 3923/-

SR.NO AMOUNT

1. CARDBOARD SHEET 55.00

2. FEVICOL 20.00

3. SIM AIRTEL 60.0

4. THERMOCOL SHEET 25.0

5. CELLO TAPE & COLOUR TAPE 40.00

Total 200/-

Page 50: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

50 Dept. of E&C, PCE

A.3 Microcontroller Coding

#include<reg52.h> // header file of microcontroller

char msg[10],notice[96];

sfr lcddata=0x90; //p1 port

sbit rs=P3^7;

sbit rw=P3^6; //initializing flash memory 24c02

sbit en=P3^5;

sbit SDA=P2^1;

sbit SCL=P2^0;

void delay(unsigned int a)

unsigned int i,j;

for(i=0;i<a;i++) //delay 1

for(j=0;j<1275;j++);

void delay2(unsigned int a) // delay 2

unsigned int i,j;

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

for(j=0;j<1;j++);

void command(unsigned char d) // lcd commands

lcddata=d;

Page 51: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

51 Dept. of E&C, PCE

en=1;

rs=0; //initialise of the LCD

rw=0;

delay(2);

en=0;

void lcd(unsigned char word)

lcddata=word;

en=1; //Data writing of the Lcd

rs=1;

rw=0;

delay(2);

en=0;

void displaydata(unsigned char *word)

unsigned char x;

for(x=0;word[x]!=0;x++) //Data writing of the LCD

lcd(word[x]);

Page 52: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

52 Dept. of E&C, PCE

void I2c_start()

SDA = 1;delay(1); //starting of data writing in memory

SCL = 1;delay(1);

SDA = 0;delay(1);

SCL = 0;delay(1);

void I2c_stop()

//stopping of data writing in memory

SCL = 0;delay(1);

SDA = 0;delay(1);

SCL = 1;delay(1);

SDA = 1;delay(1);

void I2c_write(unsigned char a) //initializing of variables for memory

unsigned char i;

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

SDA = ((a & 0x80)? 1:0 ); //checking MSB bit is '0' or'1'

a <<=1; //used for sending the bit

SCL = 1;

delay(1) ;

SCL = 0;

delay(1) ;

Page 53: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

53 Dept. of E&C, PCE

SCL = 1;

delay(1);

SCL = 0;

void write(unsigned char add,unsigned char val)

I2c_start(); delay(1); //reading from memory

I2c_write(0xA0);delay(1);

I2c_write(add); delay(1);

I2c_write(val);delay(1); //writting in memory

I2c_stop();

unsigned char I2c_read()

unsigned char i,val;

val = 0x00; //Reset in_data

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

val <<= 1;

SCL = 1; //reading from memory

val= val | SDA;

delay2(1) ;

SCL =0;

delay2(1) ;

return (val);

Page 54: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

54 Dept. of E&C, PCE

unsigned char read(unsigned char add)

unsigned char val;

I2c_start(); delay2(1); //calling of member functions

I2c_write(0xA0); delay2(1);

I2c_write(add); delay2(1); //writting in memory

I2c_start(); delay2(1);

I2c_write(0xA1); delay2(1);

val = I2c_read(); delay2(1);

I2c_stop(); //increment in value of candidate

return (val) ;

void main() //main funtion

char x1,limit,num1,num,add,i,var,x; //initializing of variable

char records='0';

command(0x38);

command(0x0C); //initializing of lcd

SCON=0x50; //initializing of timer

TMOD=0x20;

TH1=0xFD;

main1:

command(0x01);

command(0x80);

displaydata("Waiting 4 DATA"); //lcd display for waiting data from PC

main:

Page 55: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

55 Dept. of E&C, PCE

num=0;

while(1)

TR1=1;

RI=0; //initializing of serial register

while(1)

while(RI==0);

msg[num]=SBUF;

num++;

if(msg[num-1]=='E') //‟E‟ command for saving data

goto proceed;

if(msg[num-1]=='B') //‟B‟ command to show overall voting

goto proceed2;

if(msg[num-1]=='N') //‟N‟ command for erase data

goto proceed3;

RI=0;

proceed3:

command(0x01);

command(0x80); //lcd command to dispaly

displaydata("NEW DATABASE"); NEW DATABASE//

write(0,'0');

goto main1;

proceed:

TR1=1;

RI=0;

Page 56: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

56 Dept. of E&C, PCE

while(1)

while(RI==0); //loop for reading data data from port

x1=SBUF;

if(limit==1)

notice[num1]=x1;

if(x1=='#')

break;

num1++;

if(x1=='*')

limit=1;

num1=0;

RI=0;

if(notice[0]=='S') //‟s‟ command to save data

command(0x01);

command(0x80);

displaydata("SAVING DATABASE"); //lcd command to display

records=read(0);

records++;

write(0,records);

if(records=='1')

add=1;

if(records=='2')

Page 57: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

57 Dept. of E&C, PCE

add=9;

if(records=='3') // variable for calculating candidate votes

add=17;

if(records=='4')

add=25;

if(records=='5')

add=33;

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

write(add+i,notice[i+1]);

command(0xc0);

displaydata("SAVED"); //lcd command for display

delay(200);

command(0x01);

command(0x80);

displaydata("A B C D "); //lcd command for display

command(0xC0);

lcd(notice[1]);

lcd(notice[2]);

lcd(' ');

lcd(notice[3]);

lcd(notice[4]);

lcd(' ');

lcd(notice[5]);

Page 58: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

58 Dept. of E&C, PCE

lcd(notice[6]);

lcd(' '); //lcd command for display votes

lcd(notice[7]);

lcd(notice[8]);

delay(100); //delay

goto main; // go to main function

proceed2:

command(0x01); //lcd command for display

command(0x80);

displaydata("READING DATA &");

command(0xc0); //lcd command for display

displaydata("TRANSMITTING....");

var=read(0);

x=var-'0'; //incrementing votes

x=x*8;

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

TI=0;

SBUF=read(i+1);

while(TI==0);

TI=0;

SBUF='Z';

while(TI==0);

command(0x01); //lcd command for display

command(0x80);

displaydata("SENT");

Page 59: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

59 Dept. of E&C, PCE

delay(100);

goto main1;

A.4 Visual Basic (Database) Coding

A.4.1 FORM 1 //form 1

Private Sub Command1_Click() //for user name „a‟

If Text1.Text = "a" And Text2.Text = "a" Then //for password „a‟

Form1.Hide //hiding form1

Form2.Show //showing form2

Else

MsgBox ("wrong user/pASSWORD") //message box

End If

End Sub

Private Sub Command2_Click()

End //exit

End Sub

Private Sub Form_Load()

Form1.Hide

Form2.Show

End Sub

A.4.1 FORM 2

Dim c1, c2, c3, c4, choice, start, num As Integer

Dim NONAME As Boolean //intitilizing system variable

Dim Number1, Name1, choice1, c, PASSWORD As String

Page 60: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

60 Dept. of E&C, PCE

Private Sub Command1_Click()

If MSComm2.PortOpen = False Then //open port 2

MSComm2.PortOpen = True

End If

MSComm2.Output = "AT+CMGD=1" & vbCrLf

Sleep (100) //reading gsm command in inbox

MSComm2.Output = "AT+CMGF=1" & vbCrLf

End Sub

Private Sub Command10_Click()

start = InStr(Text6.Text, "+91")

Text9.Text = Mid$(Text6.Text, start, 13) //extracting text from inbox

End Sub

Private Sub Command2_Click()

Timer1.Enabled = False //enable timmer 1

Timer2.Enabled = False

MSComm2.PortOpen = False //stoping port 2

End Sub

Private Sub Command3_Click()

Command8.Enabled = False //enabling command 8

Check1.Enabled = False

MSComm1.PortOpen = False

End Sub

Private Sub Command4_Click()

Command8.Enabled = True

Check1.Enabled = True //checking port for active

If MSComm1.PortOpen = False Then

MSComm1.PortOpen = True

Page 61: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

61 Dept. of E&C, PCE

End If

End Sub

Private Sub Command5_Click()

If c1 < 10 Then

m1 = "0"

Else

m1 = ""

End If //candidate 1 variable

If c2 < 10 Then

m2 = "0" //candidate 2 variable

Else

m2 = ""

End If

If c3 < 10 Then

m3 = "0" //candidate 3 variable

Else

m3 = ""

End If

If c4 < 10 Then

m4 = "0" //candidate 4 variable

Else

m4 = ""

End If

MSComm1.Output = "E*S" & m1 & c1 & m2 & c2 & m3 & c3 & m4 & c4 & "#"

MsgBox "Data Sent to Microcontroller" //message box for data send in uc

Form2.Hide

Form1.Show

Page 62: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

62 Dept. of E&C, PCE

End Sub

Private Sub Command6_Click()

MSComm1.Output = "B" //port for overall voting data

End Sub

Private Sub Command7_Click()

MSComm1.Output = "N" //port open for erase of data

End Sub

Private Sub Command9_Click()

'MSComm2.Output = "AT+CMGF=1" & vbCrLf //gsm commands received

'MSComm2.Output = "AT+CMGR=1" & vbCrLf

Timer1.Enabled = True

End Sub

Private Sub Command8_Click()

If c1 < 10 Then

m1 = "0"

Else

m1 = ""

End If

If c2 < 10 Then

m2 = "0"

Else

m2 = ""

End If

If c3 < 10 Then

m3 = "0"

Else

m3 = ""

Page 63: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

63 Dept. of E&C, PCE

End If

If c4 < 10 Then

m4 = "0"

Else

m4 = ""

End If

MSComm1.Output = "E*w" & m1 & c1 & m2 & c2 & m3 & c3 & m4 & c4 & "#"

MsgBox "Data Sent to Microcontroller" //message box for data send in uc

End Sub

Private Sub Form_Load()

c1 = 0

c2 = 0

c3 = 0

c4 = 0

Command8.Enabled = False

Check1.Enabled = False

Timer1.Enabled = False

Timer2.Enabled = False

num = 0

NONAME = False

End Sub

Private Sub MSComm1_OnComm() // port 1 open data send to controller

If (MSComm1.CommEvent = comEvReceive) Then

c = MSComm1.Input

Text7.Text = Text7.Text & c

End If

Page 64: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

64 Dept. of E&C, PCE

If InStr(Text7.Text, "Z") > 0 Then

Text8.Text = "OVERALL VOTING STATUS:" & vbCrLf & "DAY : A - B - C - D" &

vbCrLf

a = (Len(Text7.Text) - 2) / 8

x = 1 //extractind text from gsm commands

For i = 0 To a

Text8.Text = Text8.Text & "DAY" & (i + 1) & ": " & Mid$(Text7.Text, x, 2)

Text8.Text = Text8.Text & "- " & Mid$(Text7.Text, x + 2, 2)

Text8.Text = Text8.Text & "- " & Mid$(Text7.Text, x + 4, 2)

Text8.Text = Text8.Text & "- " & Mid$(Text7.Text, x + 6, 2) & vbCrLf

x = x + 8

Next

Text7.Text = ""

End If

End Sub //command button for receiving data from gsm port

Private Sub MSComm2_OnComm()

If (MSComm2.CommEvent = comEvReceive) Then

c = MSComm2.Input

Text6.Text = Text6.Text & c

End If

If InStr(Text6.Text, "CMTI") > 0 Then

Timer1.Enabled = True

End If

End Sub

Private Sub Timer1_Timer()

Text6.Text = ""

MSComm2.Output = "AT+CMGR=1" & vbCrLf

Page 65: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

65 Dept. of E&C, PCE

Timer1.Enabled = False

Timer2.Enabled = True

End Sub

Private Sub Timer2_Timer()

start = InStr(Text6.Text, "+91") //extractind text from gsm commands

Number1 = Mid(Text6.Text, (start + 3), 10)

If InStr(Text6.Text, "VOTE") > 0 Then

start = InStr(Text6.Text, "VOTE")

choice1 = Mid(Text6.Text, (start + 4), 1) //extractind text from gsm commands

start = InStr(Text6.Text, "PASS")

PASSWORD = Mid(Text6.Text, (start + 4), 4)

findname

If NONAME = True Then

GoTo proceed

End If

If InStr(Text1.Text, Number1) = 0 Then

Text1.Text = Text1.Text & Number1 & "---" & Name1 & "---" & choice1 & vbNewLine

choice = Val(choice1)

If choice = 1 Then

c1 = c1 + 1

ElseIf choice = 2 Then //variable for candidate voting

c2 = c2 + 1

ElseIf choice = 3 Then

c3 = c3 + 1

ElseIf choice = 4 Then

c4 = c4 + 1

End If

Page 66: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

66 Dept. of E&C, PCE

If c1 > c2 And c1 > c3 And c1 > c4 Then

Label8.Caption = " 1" //maximum votes calculation

ElseIf c2 > c1 And c2 > c3 And c2 > c4 Then

Label8.Caption = " 2"

ElseIf c3 > c1 And c3 > c2 And c3 > c4 Then

Label8.Caption = " 3" //maximum votes calculation

ElseIf c4 > c1 And c4 > c2 And c4 > c3 Then

Label8.Caption = " 4"

Else

Label8.Caption = " -"

End If

Text2.Text = c1

Text3.Text = c2

Text4.Text = c3

Text5.Text = c4

MSComm2.Output = "AT+CMGS=" & Chr(34) & Number1 & Chr(34) & vbCrLf

Sleep (200)

MSComm2.Output = "YOUR VOTING IS SUCCESSFUL. THANK YOU." & Chr(26)

If (Check1 = vbChecked) Then

''''''''''''''''

If c1 < 10 Then

m1 = "0" //variable for candidate voting

Else

m1 = ""

End If

If c2 < 10 Then

m2 = "0"

Page 67: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

67 Dept. of E&C, PCE

Else

m2 = "" //variable for candidate voting

End If

If c3 < 10 Then

m3 = "0"

Else

m3 = ""

End If //variable for candidate voting

If c4 < 10 Then

m4 = "0"

Else

m4 = ""

End If //data send to flash memory

MSComm1.Output = "E*w" & m1 & c1 & m2 & c2 & m3 & c3 & m4 & c4 &

"#"

'MsgBox "Data Sent to Microcontroller"

'MsgBox "Data Sent to Microcontroller"

End If

Else //sms send for voying done

MSComm2.Output = "AT+CMGS=" & Chr(34) & Number1 & Chr(34) & vbCrLf

Sleep (200)

MSComm2.Output = "YOUR VOTING IS ALREADY DONE. VOTING ONCE IS ONLY

PERMITTED." & Chr(26)

End If

proceed:

Text6.Text = ""

Page 68: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

68 Dept. of E&C, PCE

End If

MSComm2.Output = "AT+CMGD=1" & vbCrLf

Timer2.Enabled = False

End Sub //password verification

Public Sub findname()

If Number1 = "7568501753" And PASSWORD = "0000" Then

Name1 = "Mr. RAHUL"

ElseIf Number1 = "8963040102" And PASSWORD = "1111" Then

Name1 = "Mr. VIJAY"

ElseIf Number1 = "8963040102" And PASSWORD = "2222" Then

Name1 = "Mr. VIJAY"

ElseIf Number1 = "8963040102" And PASSWORD = "3333" Then

Name1 = "Mr. VIJAY"

ElseIf Number1 = "8963040102" And PASSWORD = "4444" Then

Name1 = "Mr. VIJAY"

Else

MSComm2.Output = "AT+CMGS=" & Chr(34) & Number1 & Chr(34) & vbCrLf

Sleep (200)

MSComm2.Output = "YOUR VOTING IS UNSUCCESSFUL. Mobile

Number/Password Verification Error." & Chr(26)

NONAME = True

End If

End Sub

Page 69: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

69 Dept. of E&C, PCE

A.5 HEX File Coding

:1001B70057616974696E6720342044415441004E89

:1001C7004557204441544142415345005341564904

:1001D7004E472044415441424153450053415645FF

:1001E7004400412020422020432020442020005268

:1001F700454144494E47204441544120260054522A

:10020700414E534D495454494E472E2E2E2E0053DE

:04021700454E5400FC

:0602C400D2A07F017E00C4

:1002CA00E4FDFCC3ED9FEC9E5015E4FBFA0BBB006A

:0F02DA00010ABA04F8BBFBF50DBD00010C80E46E

:0102E90022F2

:070276001203837F017E00EB

:10027D00E4FDFCC3ED9FEC9E5015E4FBFA0BBB00B7

:0F028D00010AEB64014A70F50DBD00010C80E41D

:01029C00223F

:070353007F0112035A7F80B5

:10035A008F90D2B5C2B7C2B67F027E001202CAC25D

:02036A00B522BA

:05036C001203717F2067

:100371008F90D2B5D2B7C2B67F027E001202CAC236

:02038100B522A3

:06030F008B788A79897ADF

:10031500E4F57BAB78AA79A97A857B82758300128F

:0C0325000249FF6007120371057B80E7AE

:0103310022A9

Page 70: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

70 Dept. of E&C, PCE

:10038300D2A11202C6D2A01202CAC2A11202CAC2CA

:04039300A00202CAF8

:10039700C2A01202C6C2A11202CAD2A01202CAD2B7

:0403A700A10202CAE3

:02029D008F7A56

:10029F00E4F9E57A30E703D38001C392A1E57A252B

:1002AF00E0F57A1202C4C2A01202CA09B908E31219

:0402BF0002C4C2A013

:0102C3002218

:1002EA008F788D791203831202C67FA012029D12A3

:1002FA0002C6AF7812029D1202C6AF7912029D128F

:05030A0002C60203978A

:10033200E4F579F9E57925E0F579D2A0A2A1E433D3

:100342004279120279C2A012027D09B908E6AF7998

:010352002288

:02021B008F78DA

:10021D001202767FA012029D120279AF7812029D12

:10022D001202791202767FA112029D120279120337

:0B023D0032A907120279120397AF01EB

:010248002293

:100003007577307F3812035A7F0C12035A75985054

:10001300758920758DFD1203537BFF7A0179B71221

:10002300030FE4FFD28EC2983098FD74682FF8A6B0

:10003300990F74672FF8E6FE64456026EE644270FC

:100043000302014DEE644E6004C29880DB12035339

:100053007BFF7A0179C612030F7D30E4FF1202EAB7

:1000630080B4D28EC2983098FDAF99E572B401077F

Page 71: SMS BASED VOTING MACHINE Project Report

SMS BASED VOTING MACHINE

71 Dept. of E&C, PCE

:1000730074082573F8A607EF6423600F0573BF2A7E

:1000830006757201E4F573C29880DBE5086453706A

:10009300761203537BFF7A0179D312030FE4FF1225

:1000A300021B8F770577AD77E4FF1202EAE577B499

:1000B3003103757401E577B43203757409E577B4D8

:1000C3003303757411E577B43403757419E577B4A4

:1000D3003503757421E4F575E5742575FF740925F9

:1000E30075F8E6FD1202EA0575C3E5756480948828

:1000F30040E67FC012035A7BFF7A0179E312030FB4

:100103007FC87E001202CA1203537BFF7A0179E98A

:1001130012030F7FC012035AAF09120371AF0A1201

:10012300036CAF0B120371AF0C12036CAF0D120310

:1001330071AF0E12036CAF0F120371AF1012037184

:100143007F647E001202CA0200251203537BFF7AEA

:100153000179F612030F7FC012035A7BFF7A0279EB

:100163000512030FE4FF12021BEF24D0F57675F09E

:1001730008A4F576E4F575C3E5766480F8E575645F

:1001830080985012C299E57504FF12021B8F9930B3

:1001930099FD057580E1C29975995A3099FD12034D

:1001A300537BFF7A02791612030F7F647E001202DB

:0401B300CA02001963

:030000000203AB4D

:0C03AB00787FE4F6D8FD75817B0200032A

:10024900BB010CE58229F582E5833AF583E022506A

:1002590006E92582F8E622BBFE06E92582F8E222B4

:0D026900E58229F582E5833AF583E49322CE

:00000001FF