75
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 Atmega32 microcontroller. Actually, the aim of the 1

Voting report final

Embed Size (px)

Citation preview

Page 1: Voting report final

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 Atmega32

microcontroller. 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, keypad and Atmega32.

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 sms on the specific number from his registered mobile phone to cast

his vote. If he has entered a valid choice & password his vote will be caste. For

invalid password/choice a message is forwarded to the user.

1

Page 2: Voting report final

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

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 Need

Conventional paper-based voting can result in a number of problems like:

Unacceptable percentages of lost, stolen, or miscounted ballots.

Votes lost through unclear or invalid ballot marks.

Limited accommodations for people with disabilities.

The government has to call the day off which can incur huge losses.

2

Page 3: Voting report final

The government has to set voting booths at various places in a limited region

for people to vote.

The electronic voting machines also add to the unacceptable cost of voting.

The security personals which are hired for this job have to be paid heavily

and even then there are chances of some tragedy at the voting booth.

There are many such problems associated with such a voting system. This process

requires a change which should be friendly. Voting is a vital process in democracy.

For such a process, the efficiency, reliability, and security of the technologies

involved are critical. Here comes in the significance of sms based voting system

which offers multiple advantages over traditional paper-based voting systems like

increasing citizen access to democratic processes and encouraging participation. It not

only saves a huge amount of money but also offers mobility which is also an

important aspect.

1.5 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 service.

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 travelers 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.

3

Page 4: Voting report final

CHAPTER 2

COMPONENTS AND ITS DESCRIPTION

2.1 Basic components used in this project

Table 2.1 Component list

S.NO. Component Specification Quantity

1 Microcontroller Atmega32 1

2 LCD display 20*4 text 1

3 Resistor 330 ohm 1

4 Voltage regulator IC 7805 1

5 Capacitor 1uf, 10uf 2

6 Keypad 4*4 buttons 1

7 GSM module SIM 900A 1

8 Sim card 1

9 Connecting wires As per need

10. Soldering kit Iron, solder wire 2

2.2 Component Descriptions

2.2.1 Introduction to Atmega32 Microcontroller

A microcontroller is a single chip that contains the processor ( the CPU), non- volatile

memory for the program (ROM or Flash), volatile memory for input and output

(RAM), a clock and an I/O control unit. Also called a “Computer on a Chip”.

ATmega32 is an 8-bit high performance microcontroller of Atmel’s Mega AVR

family with low power consumption. Atmega32 is based on enhanced RISC (Reduced

Instruction Set Computing) architecture with 131 powerful instructions. Most of the

instructions execute in one machine cycle. Atmega32 can work on a maximum

frequency of 16MHz.

ATmega32 has 32 KB programmable flash memory, static RAM of 1 KB and

EEPROM of 1 KB. The endurance cycle of flash memory and EEPROM is 10,000

4

Page 5: Voting report final

and 100,000 respectively. ATmega32 is a 40 pin microcontroller. There are 32 I/O

(input/output) lines which are divided into four 8-bit ports designated as PORTA,

PORTB, PORTC and PORTD.

ATmega32 has various in-built peripherals like USART, ADC, Analog Comparator,

SPI, JTAG etc. Each I/O pin has an alternative task related to in-built peripherals. 

PIN DIAGRAM OF ATMEGA32

Fig 2.1: Pin Diagram of Atmega32

Pin Description

Pin no. Pin name Description

1 (XCK/T0)PB0 I/O PORTB, Pin 0

2 (T1) PB1 I/O PORTB, Pin 1

3 (INT2/AIN0)PB2 I/O PORTB, Pin 2

4 (OC0/AIN1)PB3 I/O PORTB, Pin 3

5 (SS)PB4 I/O PORTB, Pin 4

6 (MOSI)PB5 I/O PORTB, Pin 5

7 (MISO)PB6 I/O PORTB, Pin 6

8 (SCK)PB7 I/O PORTB, Pin 7

9 RESET Reset, Active low

10 Vcc Vcc=+5v

11 GND Ground

5

Page 6: Voting report final

12 XTAL2 External oscillator

13 XTAL1

14 (RXD)PD0 I/O PORTD, Pin 0

15 (TXD)PD1 I/O PORTD, Pin 1

16 (INT0)PD2 I/O PORTD, Pin 2

17 (INT1)PD3 I/O PORTD, Pin 3

18 (OC1B)PD4 I/O PORTD, Pin 4

19 (OC1A)PD5 I/O PORTD, Pin 5

20 (ICP)PD6 I/O PORTD, Pin 6

21 (OC2)PD7 I/O PORTD, Pin 7

22 (SCL)PC0 I/O PORTC, Pin 0

23 (SDA)PC1 I/O PORTC, Pin 1

24 (TCK)PC2 I/O PORTC, Pin 2

25 (TMS)PC3 I/O PORTC, Pin 3

26 (TD0)PC4 I/O PORTC, Pin 4

27 (TD1)PC5 I/O PORTC, Pin 5

28 (TOSC1)PC6 I/O PORTC, Pin 6

29 (TOSC2)PC7 I/O PORTC, Pin 7

30 Avcc Vcc for ADC

31 GND Ground

32 Aref Analog ref. pin

33 (ADC7)PA7 I/O PORTA, Pin 0

34 (ADC6)PA6 I/O PORTA, Pin 0

35 (ADC5)PA5 I/O PORTA, Pin 0

36 (ADC4)PA4 I/O PORTA, Pin 0

37 (ADC3)PA3 I/O PORTA, Pin 0

38 (ADC2)PA2 I/O PORTA, Pin 0

39 (ADC1)PA1 I/O PORTA, Pin 0

40 (ADC0)PA0 I/O PORTA, Pin 0

Table 2.1: Atmega32 Pin Diagram Description

Features of atmega32

6

Page 7: Voting report final

The main features of Atmega32 are:

32K bytes of In-System Programmable Flash Program memory with Read-

While-Write capabilities

1024 bytes EEPROM

2K byte SRAM

32 general purpose I/O lines

32 general purpose working registers

a JTAG interface for Boundary scan

On-chip Debugging support and programming

3 flexible Timer/Counters with compare modes

Internal and External Interrupts

a serial programmable USART

a byte oriented Two-wire Serial Interface

an 8-channel, 10-bit ADC

a programmable Watchdog Timer with Internal Oscillator

an SPI serial port

6 software selectable power saving modes

Interrupts

In short, an interrupt is a way for an external (or, sometimes, internal) event to pause

the current processor's activity, so that it can complete a brief task before resuming

execution where it left off. Atmega32 in total has 21 interrupts available. The

available interrupts are categorized in two classes:

External Interrupts- Out of the twenty one interrupts available, four interrupts are

directly present on controller pins to handle the interrupts generated by external

sources, so they are called as external interrupts. The four available interrupts and

their respective pins are shown in the figure below in their order of priority.

Fig. 2.2: External Interrupts

7

Page 8: Voting report final

 Internal Interrupts- The remaining seventeen (17) interrupts are available for

internal use and support the precise and efficient operation of various peripherals like

ADC, Timers, and USARTs etc. The table below describes the available internal

interrupts in the order of their priority.

Fig. 2.3: Internal Interrupts

Following is what happens when an interrupt occurs:

Microcontroller normally completes the instruction which is being executed.

The program control transfers to Interrupt Service Routine (ISR). Each

interrupt have an associated ISR which is a piece of code which tells the

microcontroller what to do when an interrupt has occurred.

Execution of ISR is performed by loading the beginning address of the

corresponding ISR into program counter.

Execution of ISR continues until the return from the interrupt instruction

(RETI) is encountered.

When ISR is complete, the microcontroller resumes processing where it left

off before the interrupt occurred, i.e., program control is reverted back to the

main program.

USART

Communication between two entities is important for the information flow to take

place. In general the information transport system can be parallel in which the

complete byte of data is sent at a time, with each bit having a separate dedicated line

or it can be serial where only one communication line is available which is shared by

8

Page 9: Voting report final

all the bits sequentially. The pros and cons of these two systems are equivalent and

selection between the two depends on the application.

 Data can be exchanged using parallel or serial techniques. Setup for parallel data

transfer is not cost effective but is a very fast method of communication. Serial

communication is cost effective because it requires only a single line of connection

but on the other hand is a slow process in comparison to parallel communication.

There are two methods for serial data communication:

(i) Synchronous and

(ii) Asynchronous communication.

In Synchronous communication method complete block (characters) is sent at a time.

It doesn’t require any additional bits (start, stop or parity) to be added for the

synchronization of frame. The devices are synchronized by clock. And in

asynchronous communication data transmission is done byte by byte i.e., one byte at

a time. The additional bits are added to complete a frame.

 In synchronous communication the frame consists of data bits while in asynchronous

communication the total number of bits in a frame may be more than the data bits.

There are three ways in which serial communication can be done:

1. Simplex: Transmission is done in one direction.

2. Half duplex: Transmission can be done in both the direction but one side at a

time.

3. Full duplex: Transmission can be done in both the direction simultaneously.

Atmega32 is equipped with three different kinds of serial communication

peripheral systems:

Serial USART

SPI (Serial Peripheral Interface)

TWI (Two wire Interface)

 

SERIAL USART (universal synchronous asynchronous receiver and

transmission/ transmitter):  

Serial USART provides full-duplex communication between the transmitter and

receiver. Atmega16 is equipped with independent hardware for serial USART

communication. Pin-14 (RXD) and Pin-15 (TXD) provide receive and transmit

interface to the microcontroller.

9

Page 10: Voting report final

Fig 2.4: USART Pins

Atmega32 USART provides asynchronous mode of communication and do not have a

dedicated clock line between the transmitting and receiving end. The synchronization

is achieved by properly setting the baud rate, start and stop bits in a transmission

sequence.

Start bit and stop bit: These bits are use to synchronize the data frame. Start bit is

one single low bit and is always given at the starting of the frame, indicating the next

bits are data bits. Stop bit can be one or two high bits at the end of frame, indicating

the completion of frame.

 

Baud Rate: In simple words baud rate is the rate at which serial data is being

transferred.

Atmega32 USART has following features:

Different Baud Rates.

Variable data size with options ranging from 5bits to 9bits.

One or two stop bits.

Hardware generated parity check.

USART can be configured to operate in synchronous mode.

Three separate interrupts for RX Complete, TX complete and TX data register

empty. 

USART Registers

To use the USART of Atmega32, certain registers need to be configured.

.UBRR: USART Baud Rate Registers. Basically use to set the baud rate of USART

10

atmega32

Page 11: Voting report final

UDR: USART data register

UCSR: USART control and status register. It’s is basically divided into three parts

UCSRA, UCSRB and UCSRC. These registers are basically used to configure the

USART.

1. UCSRA: (USART Control and Status Register A)

RXC (USART Receive Complete): RXC flag is set to 1 if unread data exists in

receive buffer, and set to 0 if receive buffer is empty.

TXC (USART Transmit complete): TXC flag is set to 1 when data is completely

transmitted to Transmit shift register and no data is present in the buffer register

UDR.

UDRE (USART Data Register Empty): This flag is set to logic 1 when the transmit

buffer is empty, indicating it is ready to receive new data. UDRE bit is cleared by

writing to the UDR register.

 

2. UCSRB: (USART Control and Status Register B)

RXCIE: RX Complete Interrupt Enable

When 1--RX complete interrupt is enabled.

When 0--RX complete interrupt is disabled.

TXCIE: TX Complete Interrupt Enable

When 1--TX complete interrupt is enabled.

When 0--TX complete interrupt is disabled.

UDRIE: USART Data Register Empty Interrupt Enable

When 1--UDRE flag interrupt is enabled.

When 0--UDRE flag interrupt is disabled.

11

Page 12: Voting report final

RXEN: Receiver Enabled

When 1--USART Receiver is enabled.

When 0--USART Receiver is disabled.

TXEN: Transmitter Enabled

When 1--USART Transmitter is enabled.

When 0--USART Transmitter is disabled.

3. UCSRC: (USART Control and Status Register C)

The transmitter and receiver are configured with the same data features as configured

in this register for proper data transmission.

URSEL: USART Register select. This bit must be set due to sharing of I/O location

by UBRRH and UCSRC

UMSEL: USART Mode Select,

When 1--Synchronous Operation

When 0--Asynchronous Operation

UPM [0:1]: USART Parity Mode, Parity mode selection bits.

USBS: USART Stop Select Bit,

When 0--1 Stop Bit

When 1 --2 Stop Bits

UCSZ [0:1]: The UCSZ[1:0] bits combined with the UCSZ2 bit in UCSRB sets size

of data frame i.e., the number of data bits. The table shows the bit combinations with

respective character size.

 

UCSZ2 UCSZ1 UCSZ0 Character Size

0 0 0 5-bit

12

Page 13: Voting report final

0 0 1 6-bit

0 1 0 7-bit

0 1 1 8-bit

1 0 0 Reserved

1 0 1 Reserved

1 1 0 Reserved

1 1 1 9-bit

Table 2.3: UCSZ values and their meaning

4. UDR: (USART Data Register)

 

The USART Data receive and data transmit buffer registers share the same address

referred as USART UDR register, when data is written to the register it is written in

transmit data buffer register (TXB). Received data is read from the Receive data

buffer register (RXB).

5. UBRRH & UBRRL (USART Baud Rate Registers)

The UBRRH register shares the same I/O address with the UCSRC register, The

differentiation is done on the basis of value of URSEL bit.

When URSEL=0; write operation is done on UBRRH register.

When URSEL=1; write operation is done on UCSRC register.

 

The UBRRH and UBRRL register together stores the 12-bit value of baud rate,

UBRRH contains the 4 most significant bits and UBRRL contains the other 8 least

significant bits. Baud rates of the transmitting and receiving bodies must match for

successful communication to take place.

13

Page 14: Voting report final

UBRR register value is calculated by the following formula:

2.2.2 LCD Display

Fig. 2.5: 20*4 LCD Display

LCD is used to present textual information to the users. A 20x4 LCD means it can

display 20 characters per line and there are 4 such lines. In this LCD each character is

displayed in 5x7 pixel matrix. This LCD has two registers:

1. Command/Instruction Register - stores the command instructions given to

the LCD. A command is an instruction given to LCD to do a predefined task

like initializing, clearing the screen, setting the cursor position, controlling

display etc.

2. Data Register - stores the data to be displayed on the LCD. The data is the

ASCII value of the character to be displayed on the LCD.

LCD has inbuilt controllers which process the commands and displays on the screen.

Functions for LCD are provided in the appendices.

Following is the table showing various command codes for the LCD:

 

14

Hex Code Command to LCD Instruction Register

01 Clear screen display

02 Return home

04 Decrement cursor

06 Increment cursor

0E Display ON, Cursor ON

80 Force the cursor to the beginning of the 1st line

C0 Force cursor to the beginning of the 2nd line

Page 15: Voting report final

Table 2.4: Commonly used LCD Command codes

Pin configuration of LCD

Following table gives the brief description of LCD pins:

Pin Symbol Description

1 VSS Ground

2 VCC Main power supply

3 VEE Power supply to control contrast

4 RS Register Select

5 R/W Read/write

6 EN Enable

7 DB0 data pins

8 DB1

9 DB2

10 DB3

11 DB4

12 DB5

13 DB6

14 DB7

15 Led+ Backlight VCC

16 Led- Backlight Ground

Table 2.5: Pin Configuration LCD display

Programming the LCD

1. Data pin8 (DB7) of the LCD is busy flag and is read when R/W = 1 & RS = 0.

When busy flag=1, it means that LCD is not ready to accept data since it is

15

Page 16: Voting report final

busy with the internal operations. Therefore before passing any data to LCD,

its command register should be read and busy flag should be checked.

2. To send data on the LCD, data is first written to the data pins with R/W = 0 (to

specify the write operation) and RS = 1 (to select the data register). A high to

low pulse is given at EN pin when data is sent. Each write operation is

performed on the positive edge of the Enable signal.

3. To send a command on the LCD, a particular command is first specified to the

data pins with R/W = 0 (to specify the write operation) and RS = 0 (to select

the command register). A high to low pulse is given at EN pin when data is

sent.

2.2.3. Resistor

A resistor is a passive two-terminal electrical component that implements electrical

resistance as a circuit element. Resistors act to reduce current flow, and, at the same

time, act to lower voltage levels within circuits.

Fig. 2.6: 330 ohm resistor

2.2.4. Voltage regulated IC

16

Page 17: Voting report final

The 78xx (sometimes L78xx, LM78xx, MC78xx...) is a family of self-contained

fixed linear voltage regulator integrated circuit. The 78xx family is commonly used in

electronic circuits requiring a regulated power supply due to their ease-of-use and low

cost. For ICs within the family, the xx is replaced with two digits, indicating the

output voltage (for example, the 7805 has a 5 volt output, while the 7812 produces

12 volts). The 78xx line are positive voltage regulators: they 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.

Fig.2.7: Pin Diagram 7805

2.2.5 Capacitor

A capacitor (originally known as a condenser) is a passive two-terminal electrical

component used to store energy electrostatically in an electric field. The forms of

practical capacitors vary widely, but all contain at least two electrical

conductors (plates) separated by a dielectric (i.e. insulator). The conductors can be

thin films, foils or sintered beads of metal or conductive electrolyte, etc. The "non

conducting" dielectric acts to increase the capacitor's charge capacity. A dielectric can

be glass, ceramic, plastic film, air, vacuums, paper, mica, oxide layer etc. Capacitors

are widely used as parts of electrical circuits in many common electrical devices.

Unlike a resistor, an ideal capacitor does not dissipate energy. Instead, a capacitor

stores energy in the form of an electrostatic field between its plates.

17

Page 18: Voting report final

Fig 2.8: Capacitor

2.2.6 4*4 keypad

Keypad is most widely used input device to provide input from the outside world to

the microcontroller. The keypad makes an application more users interactive. Keypad

is organized as a matrix of switches in rows and column. The concept of interfacing

keypad with the MCU is simple. Every number is assigned two unique parameters,

i.e., row and column number (n(R, C) for example 6 (2, 3)). Hence every time a key is

pressed the number is identified by detecting the row and column number of the key

pressed.

Initially all the rows are set to zero by the controller and the columns are scanned to

check if any key is pressed. In case no key is pressed the output of all the columns

will be high.

Fig 2.9: Arrangement in Keypad

18

Page 19: Voting report final

Whenever a key is pressed the row and column corresponding to the key will get

short, resulting in the output of the corresponding column goes to go low (since we

have made all the rows zero). This gives the column number of the pressed key.

Once the column number is detected, the controller set’s all the rows to high. Now

one by one each row is set to zero by controller and the earlier detected column is

checked if it becomes zero. The row corresponding to which the column gets zero is

the row number of the digit.

The above process is very fast and even if the switch is pressed for a very small

duration of time the controller can detect the key which is pressed. The controller

displays the number corresponding to the row and column on the LCD.

2.2.7 GSM MODULE

Fig 2.10: GSM Module

A GSM 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. GSM modem requires

a SIM card from a wireless carrier in order to operate. GSM modem uses AT

commands to control. Both GSM modems and dial-up modems support a common set

of standard AT commands. 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, we can do things like:

19

Page 20: Voting report final

1. Reading, writing and deleting SMS messages.

2. Sending SMS 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.

Features of SIM900A

Quad-Band 850/ 900/ 1800/ 1900 MHz

GPRS multi-slot class 10/8

GPRS mobile station class B

Dimensions: 24*24*3 mm

Weight: 3.4g

Control via AT commands (GSM 07.07 ,07.05 and SIMCOM enhanced AT

Commands)

SIM application toolkit

Supply voltage range 3.4 ... 4.5 V

Low power consumption

Operation temperature: -30 °C to +80 °C

AT Commands

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

Attention. Every command line starts with “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

20

Page 21: Voting report final

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 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 tasks, such as opening or closing facility locks

(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).

21

Page 22: Voting report final

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 modems designed for 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 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.

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

22

Page 23: Voting report final

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>

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

23

Page 24: Voting report final

a line feed character respectively. The final results code "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+CGMI Nokia OK

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 command "+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

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

our SMS tutorial”. Nokia

OK

24

Page 25: Voting report final

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

of SMS messages:

+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.

AT

.OK

AT+CMGF=1 .

.OK

AT+CMGW="+7568501753"

> A simple demo of SMS text messaging.

+CMGW:

.OK

AT+CMSS=1

25

Page 26: Voting report final

+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++.

How to receive SMS messages

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

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

26

Page 27: Voting report final

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

2.2.8 Sim card

A subscriber identity module or subscriber identification module (SIM) is an

integrated circuit that securely stores the international mobile subscriber identity

(IMSI) and the related key used to identify and authenticate subscribers on mobile

telephony devices (such as mobile phones and computers). A SIM card contains its

unique serial number (ICCID), international mobile subscriber identity (IMSI),

security authentication and ciphering information, temporary information related to

the local network

Fig. 2.11: Sim card

27

Page 28: Voting report final

2.2.9. Connecting wires

They are the building block of the circuit. They are used to create current/signal path

between various components on the circuit board.

2.2.10 Soldering kit

Fig.2.12: Soldering kit

Soldering is a process in which two or more metal items are joined together by

melting and flowing a filler metal (solder) into the joint, the filler metal having a

lower melting point than the adjoining metal. Soldering differs from welding in that

soldering does not involve melting the work pieces. In brazing, the filler metal melts

at a higher temperature, but the work piece metal does not melt. In the past, nearly all

solders contained lead, but environmental concerns have increasingly dictated use of

lead-free alloys for electronics and plumbing purposes.

28

Page 29: Voting report final

CHAPTER 3

CIRCUIT AND BLOCK DIAGRAM OF PROJECT

3.1 Block Diagram of Project

VV

Fig 3.1: Block Diagram of Project

3.1.1 Block Diagram Description

1. POWER SUPPLY UNIT

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 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

29

2- ATMEGA32

uC

1- POWER SUPPLY

4- KEYPAD 5-LCD

3- GSM MODULE

6- MOBILE

Page 30: Voting report final

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 3.2: 7805 Voltage Regulator IC

2. ATMEGA32 Microcontroller

In this project we interfaced ATMEGA32 microcontroller with LCD, KEYPAD AND

GSM MODULE. The ATMEGA32 is 40 pin IC packaged in DIP package. It is

derivative of AVR family, from Atmel

ATMEGA32 Microcontroller is the heart of the circuit as it controls all the functions

of the system.

3. 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 the microcontroller through a cable. 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.

4. KEYPAD

A keypad is a set of buttons arranged in a block or "pad" which usually bear digits,

symbols and usually a complete set of alphabetical letters. If it mostly contains

numbers then it can also be called a numeric keypad. Keypad is interfaced to provide

numeric input.

30

Page 31: Voting report final

5. LCD

In this project 20*4 LCD is used. This LCD is interface with ATmega32 at port B. It

is used to display all the relevant information.

6. 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).

3.2 Circuit Diagram

Fig: 3.3: Circuit Diagram

31

Page 32: Voting report final

3.2.1 Circuit Description

Here PORT B is connected to the LCD to display data from the microcontroller to the

LCD. PORT D ( 0th and 1st) is used to send and receive data via serial port and is

used for GSM module. PORT A and PORT C are used for interfacing of keypad with

the controller. PORT A’s pins (PA0-PA3) are internally pulled up and PORT C’s pins

(PC0-PC3) are used to provide ground to detect the pressed button of keypad.

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.

DC voltage is supplied with the help of 9v battery to the voltage regulator IC 7805

with the help of two capacitors to reduce the heating of IC. 7805 produce 5v DC from

9v supply. A led is placed with the output pin with a series resistor of 330 ohm.

From this power supply circuit, 5v and ground is connected to the various circuit

components.

32

Page 33: Voting report final

CHAPTER 4

FLOW CHART AND ALGORITHMS

4.1 Flow Chart of Project

Fig.4.1: Flow chart of Voting System

33

INITIALIZE GMS

Page 34: Voting report final

4.2 flow of Microcontroller Programming

Step 1: Power supply ON.

Step 2: Initializing LCD, GSM and USART

Step 3: Display initial menu on LCD and let user enter his choice

Choices available are:

1. Register

2. Generate password

2.1 for all user

2.2 for specific user

3. Display results

Step 4: display user choice on lcd

Step 5: If choice is 1, then let the user enter his 5 digit voter id number and 10 digit

mobile number, then using usart send data to gsm module to send a register

confirmation message to the user on his entered number while registering.

No voter id number can have two number associated with it.

Step 6: If choice of user is 2, then display the other menu for user asking about

whether he want to generate password for all user or a specific user.

User will enter 1 for all users and 2 for specific user.

Step 7: If choice of user is 3, then display the results of election.

Before this display, Messages received from registered users are decoded and counter

of there voted candidate is increased.

34

Page 35: Voting report final

CHAPTER 5

SOFTWARE & HARDWARE TOOL

5.1 Software Tools:

5.1.1 AVR studio 6

AVR Studio was created by Atmel in order to help developers to create applications

for AVR microcontrollers using C/C++ programming languages. This piece of

software comes with a large number of tutorials, which allow the users to get familiar

with the application. The program stands as a complete pack for programmers that use

C++ and other programming languages.

5.1.2 Proteus Professional V7.10

Proteus is software for 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.

5.1.3 Programming language

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

5.2 Hardware Tools:

1. USBasp

USBasp is a USB in-circuit programmer for Atmel AVR controllers. It simply

consists of an ATMega88 or an ATMega8 and a couple of passive components. The

programmer uses a firmware-only USB driver, no special USB controller is needed.

Features

Works under multiple platforms. Linux, Mac OS X and Windows are tested.

No special controllers or smd components are needed.

Programming speed is up to 5kBytes/sec.

SCK option to support targets with low clock speed (< 1,5MHz).

Planned: serial interface to target (e.g. for debugging).

35

Page 36: Voting report final

Fig.5.1: USBasp programmer

2. Com to serial connector

Fig.5.2: serial connector

A serial cable is a cable used to transfer information between two devices using a

serial communication protocol. The form of connectors depends on the particular

serial port used. A cable wired for connecting two DTEs directly is known as a null

modem cable

36

Page 37: Voting report final

CHAPTER 6

APPLICATIONS & ADVANTAGES

6.1 Applications

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

errors.

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.

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

system is difficult to implement.

This system can be used in colleges, society and various other places for

elections.

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

welfare association, “panchayat” level election and other society level

elections.

It could also be used to conduct opinion polls during annual shareholders

meeting.

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.

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

6.2 Advantages

Voting system using sms offer multiple advantages over traditional paper-based

voting systems- advantages that increase citizen access to democratic processes and

encourage participation.

Reduced costs- SMS voting systems reduce the materials required for printing and

distributing ballots. GSM based voting, in particular, offers superior economies of

scale in regard to the size of the electoral roll.

37

Page 38: Voting report final

Increased participation and voting options- SMS voting offers increased convenience

to the voter, encourages more voters to cast their votes remotely, and increases the

likelihood of participation for mobile voters. Additionally, it permits access to more

information regarding voting options.

Greater speed and accuracy placing and tallying votes- SMS voting's step-by-step

processes help minimize the number of miscast votes. The electronic gathering and

counting of ballots reduces the amount of time spent tallying votes and delivering

results.

Flexibility – SMS voting can support few languages, and the flexible design allows

up-to-the minute ballot modifications.

38

Page 39: Voting report final

CHAPTER 7

FUTURE SCOPE & LIMITATIONS

7.1 Future Scope

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

Number of candidates could be increased.

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

instantly from the machine itself.

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

the central server.

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.

7.2 Limitations

Number of candidates is less.

Major limitation is network problem.

Less storage of data.

39

Page 40: Voting report final

CHAPTER 8

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.

40

Page 41: Voting report final

REFERENCES

1) Book:Elliot Williams. Make - AVR Programming. Washington, DC : O'Reilly, 2014

2) Article in a Journal:Akshay Verma. “GSM module interfacing”. GSM module, Feb, 2009

3) World Wide Web:Avinash Gupta. “SMS based voting system. Internet: http://extremeelectronics.co.in/avr-projects/sms-based-voting-system, 28 aug, 2002 [sep. 16, 2014].

41

Page 42: Voting report final

Appendices

A.1 Functions for LCD

void lcd_cmd(int);

void lcd_data(int);

void dis_cmd(int);

void dis_data(int);

void lcd(void);

void string(char *str);

void lcd_num(unsigned int abc)

{

dis_cmd(0x04);

unsigned int d=0;

while(abc!=0)

{

d=abc%10;

dis_data(d+48);

abc=abc/10;

}

dis_cmd(0x06);

}

void lcd_cmd(int a)

{

PORTB=a;

42

Page 43: Voting report final

PORTB&=~(1<<rs);

PORTB&=~(1<<rw);

PORTB|=(1<<en);

_delay_ms(1);

PORTB&=~(1<<en);

}

void lcd_data(int a)

{

PORTB=a;

PORTB|=(1<<rs);

PORTB&=~(1<<rw);

PORTB|=(1<<en);

_delay_ms(1);

PORTB&=~(1<<en);

}

void dis_cmd(int a)

{

int div;

div=a&0xF0;

lcd_cmd(div);

div=((a<<4)&0xF0);

lcd_cmd(div);

}

43

Page 44: Voting report final

void dis_data(int a)

{

int div;

div=a&0xF0;

lcd_data(div);

div=((a<<4)&0xF0);

lcd_data(div);

}

void lcd(void)

{

dis_cmd(0x02);

dis_cmd(0x28);

dis_cmd(0x0C);

dis_cmd(0x06);

}

void string (char *str)

{

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

{

dis_data(str[i]);

}

}

44

Page 45: Voting report final

A.2 Functions for USART

void uart_init()

{ UCSRB|=(1<<RXEN)|(1<<TXEN)|(1<<RXCIE);

UCSRC|=(1<<URSEL)|(1<<UCSZ1)|(1<<UCSZ0);

UBRRL=51;

}

int uart_recieve()

{

while((UCSRA&(1<<RXC))==0);

return(UDR);

}

void uart_transmit(char data)

{ while((UCSRA&(1<<UDRE))==0);

UDR=data;

}

45

Page 46: Voting report final

A.3 Function for sending sms

void send_sms_option1(char str1[])

{

uart_transmit('A');

uart_transmit('T');

uart_transmit('+');

uart_transmit('C');

uart_transmit('M');

uart_transmit('G');

uart_transmit('F');

uart_transmit('=');

uart_transmit('1');

uart_transmit(0x0d);

_delay_ms(1000);

uart_transmit('A');

uart_transmit('T');

uart_transmit('+');

uart_transmit('C');

uart_transmit('M');

uart_transmit('G');

uart_transmit('S');

uart_transmit('=');

int i=0;

46

Page 47: Voting report final

uart_transmit('"');

while(i!=10)

{

uart_transmit(mob[x][i]);

i++;

}

uart_transmit('"');

uart_transmit(';');

uart_transmit(0x0d);

i=0;

_delay_ms(2000);

while(str1[i]!= '\0')

{

uart_transmit(str1[i]);

i++;

}

uart_transmit(0x1a);

uart_transmit(0x0D);

}

47

Page 48: Voting report final

A.4 Function for entering mobile num/voter id

void getnum(int m)

{

int q=0;

int i=0xc0;

while (q<10)

{

PORTC=0b11111110;

_delay_ms(10);

if ((PINA&0b00000001)==0)

{

while((PINA&0b00000001)==0);

dis_cmd(i);

dis_data('1');

mob[m][q]='1';

i++;

q++;

}

if ((PINA&0b00000010)==0)

{

while((PINA&0b00000010)==0);

48

Page 49: Voting report final

dis_cmd(i);

dis_data('2');

mob[m][q]='2';

i++;

q++;

}

if ((PINA&0b00000100)==0)

{

while((PINA&0b00000100)==0);

dis_cmd(i);

dis_data('3');

mob[m][q]='3';

i++;

q++;

}

PORTC=0b11111101;

_delay_ms(10);

if ((PINA&0b00000001)==0)

{

49

Page 50: Voting report final

while((PINA&0b00000001)==0);

dis_cmd(i);

dis_data('4');

mob[m][q]='4';

i++;

q++;

}

if ((PINA&0b00000010)==0)

{

while((PINA&0b00000010)==0);

dis_cmd(i);

dis_data('5');

mob[m][q]='5';

i++;

q++;

}

if ((PINA&0b00000100)==0)

{

while((PINA&0b00000100)==0);

dis_cmd(i);

dis_data('6');

50

Page 51: Voting report final

mob[m][q]='6';

i++;

q++;

}

PORTC=0b11111011;

_delay_ms(10);

if ((PINA&0b00000001)==0)

{

while((PINA&0b00000001)==0);

dis_cmd(i);

dis_data('7');

mob[m][q]='7';

i++;

q++;

}

if ((PINA&0b00000010)==0)

{

while((PINA&0b00000010)==0);

dis_cmd(i);

51

Page 52: Voting report final

dis_data('8');

mob[m][q]='8';

q++;

i++;

}

if ((PINA&0b00000100)==0)

{

while((PINA&0b00000100)==0);

dis_cmd(i);

dis_data('9');

mob[m][q]='9';

i++;

q++;

}

PORTC=0b11110111;

_delay_ms(10);

if ((PINA&0b00000010)==0)

{

52

Page 53: Voting report final

while((PINA&0b00000010)==0);

dis_cmd(i);

dis_data('0');

mob[m][q]='0';

i++;

q++;

}

}

if (q==10)

{

_delay_ms(1000);

dis_cmd(0x01);

_delay_ms(1);

dis_cmd(0x80);

string("wait.. registering");

}

}

53

Page 54: Voting report final

A.5 AT commands for GSM

SMS Text mode:

54