Saturday, 5 October 2013

ELECTRONIC VOTING MACHINE USING ATmega16

Now a days Electronic Voting Machine is used for elections. So make your own EVM from here.

Introduction :-
                      In this project we use ATmega16 controller and a 16x2 alphanumeric LCD and Toggle switches. Program is loaded in the ATmega16 and the voting machine is ready to use.


Lcd Interfacing :-
                              see.. LCD INTERFACING WITH ATmega16 IN 4-BIT MODE


ATmega16 :-
                       

Components required :-

  1. 10k ohm registance
  2. 10k ohm variable registance
  3. 8 MHZ crystal oscilltor
  4. 16x2 LCD
  5. ATmega16 IC
  6. 12v battery 
  7. Toggle button -5
  8. 7805 IC
  9. 330 ohm resistance
  10. 1N4007 diode
  11. 1000uf capacitor
  12. Green LED



Circuit Diagram :-
                               
3 buttons are for votes and 4th button is for result.


Code (compiled in CVAVR) :-  

                                                (see.. CVAVR TUTORIAL (CODE VISION AVR))

Note :- In CVAVR program window delete all the lines and paste the code given below. because there are so much unnecessary lines.

-----------------------------------------------------------------------------------------------------------------------

#include <mega16.h>
#include <delay.h>
#include <stdlib.h>
// Alphanumeric LCD Module functions
#asm
   .equ __lcd_port=0x15 ;PORTC
#endasm
#include <lcd.h>

// Declaration of global variables
int i,j,k; 
char a[10], b[10], c[10];
void main(void)
{
    // Port A initialization    
    PORTA=0x00;
    DDRA=0x00;
    // Port C initialization
    PORTC=0x00;
    DDRC=0x00;
    
     i=j=k=0;
    
    // LCD module initialization
    lcd_init(16);

    while (1)
    {
      //your code
        lcd_gotoxy(0,0);
        lcd_putsf("ENTER YOUR VOTE");
        lcd_gotoxy(0,1);
        lcd_putsf("1>BJP 2>JP 3>BSP");
        if(PINA.0==1)
        {
            i=i+1;
            delay_ms(100);
            lcd_clear();
            lcd_putsf("vote accepted");
            delay_ms(100);
            lcd_clear();
            lcd_gotoxy(0,0);
        }
        if(PINA.1==1)
        {
            j=j+1;
            lcd_clear();
            delay_ms(100);
            lcd_putsf("vote accepted");
            delay_ms(100);
            lcd_clear();
            lcd_gotoxy(0,0);
        }
        if(PINA.2==1)
        {
            k=k+1;
            lcd_clear();
            delay_ms(100);
            lcd_putsf("vote accepted");
            delay_ms(100);
            lcd_clear();
            lcd_gotoxy(0,0);
        }
        if(PINA.3==1)
        {
            if(i>j)
            {
                if(i>k)
                {
                    lcd_clear();
                    itoa(i,a);
                    lcd_putsf("winner is BJP=");
                    lcd_puts(a);
                    delay_ms(500);
                }
            }
            else if(j>k)
            {
                lcd_clear();
                itoa(j,b);
                lcd_putsf("winner is JP=");
                lcd_puts(b);
                delay_ms(500);
            }
            else
            {
                lcd_clear();
                itoa(k,c);
                lcd_putsf("winner is BSP=");
                lcd_puts(c);
                delay_ms(500);
            }
        }
    }    
      
}

-----------------------------------------------------------------------------------------------------------------------

Proteus simulation:-











19 comments:

Anonymous said...

sir,
u have included one lcd header file but there no availability of the header u included in it. so post the lcd.h file.

Anonymous said...

sir,
u have included one lcd header file but there no availability of the header u included in it. so post the lcd.h file.

Unknown said...

Here is no need of lcd.h
... This code is compiled in cvavr ...
Download cvavr nd see cvavr tutorial in the blog

Anonymous said...

LCD IS SHOWING NOTHING

Unknown said...

Try reducing the contrast of lcd

Mahendra D said...

This program keep accepting multiple votes even for a single press. Kindly reply as soon as possible how to resolve it. Thank You

Unknown said...

U cn use while(1) or break conditions in each loop.

Anonymous said...

Sir! i couldn't get the hex file of the code.. kindly help me to fix it !!!

Unknown said...

Can you please tell me the error in detail

Unknown said...

Very nice project can you give me its working in theory ??
daniyalsyed10@gmail.com
Thank you i want to make it..

Unknown said...

full working theory is already given... please read full post carefully... you will understand very easily.. !!

Unknown said...
This comment has been removed by the author.
Unknown said...

Sir,
Can I know where did you get Atmega16.h library?

Anonymous said...

sir which switch have you used in proteus.. the exact name? will spst push button do the same thing?

Can Crusher said...

This is a very great article.thanks for sharing.

Anonymous said...

Is simple push button can work for this

Unknown said...

Thank u so much for the project. Bt no. Of votes is not showing in the coding. So how it can b done?

Unknown said...

Yes simple push button will work.

Unknown said...

I am not storing votes in code. They will be direcrly printed on lcd. If you want to store you can modify the code accordingly.