THE ELECTRONIC VOTING MACHINE using ATMEGA 16



#include<avr/io.h>
#include<util/delay.h>
#include"lcd.h";
int main(void)
{

char a=0,b=0,c=0,d=0;
int i,j;
char x[5],y[5],z[5],m[5];
DDRC=0b11111111;
DDRD=0b11111111;
DDRA=0b00000000;
DDRB=0b11111111;
lcd_init();
for(j=0;j<3;j++)
{
lcdcmd(0x01);
display("***WELCOME TO 2017 ELECTION***");
for(i=0;i<33;i++)
{
lcdcmd(0x18);
_delay_ms(10);
}}
lcdcmd(0x01);
lcdcmd(0x83);
display("**PRESS**");
_delay_ms(2000);
lcdcmd(0x01);
display("1->BJP");
_delay_ms(200);
lcdcmd(0x88);
display("2->CONG");
_delay_ms(200);
lcdcmd(0xc0);
display("3->AAP");
_delay_ms(200);
lcdcmd(0xc8);
display("4-->SP");
_delay_ms(300);

lcdcmd(0x01);
display("ENTER YOUR VOTE");
_delay_ms(200);
lcdcmd(0x01);
display("BJP-");
lcdcmd(0x88);
display("CONG-");
lcdcmd(0xc0);
display("AAP-");
lcdcmd(0xc8);
display("SP  -");
while(1)
{  
if(PINA==0b00000001)
{
a++;
itoa(a,x,10);
lcdcmd(0x84);
PORTB=0b10000000;
display(x);
_delay_ms(500);
PORTB=0b00000000;

}
else if(PINA==0b00000010)
{
b++;
itoa(b,y,10);
lcdcmd(0x8D);
PORTB=0b10000000;
display(y);
_delay_ms(500);
PORTB=0b00000000;
}
else if(PINA==0b00000100)
{
c++;
itoa(c,z,10);
lcdcmd(0xc4);
PORTB=0b10000000;
display(z);
_delay_ms(500);
PORTB=0b00000000;
}
else if(PINA==0b00001000)
{
d++;
itoa(d,m,10);
lcdcmd(0xcd);
PORTB=0b10000000;
display(m);
_delay_ms(500);
PORTB=0b00000000;
}
if(PINA==0b00010000)
{
lcdcmd(0x01);
lcdcmd(0x81);
display("WIN-");
PORTB=0b10000000;
if((a>b)&&(a>c)&&(a>d))
{
display("BJP");
lcdcmd(0xc0);
display("*****************");
_delay_ms(1000);
PORTB=0b00000000;
}
else if((b>a)&&(b>c)&&(b>d))
{

display("CONG");
lcdcmd(0xc0);
display("******************");
_delay_ms(1000);
PORTB=0b00000000;
}
else if((c>b)&&(c>a)&&(c>d))
{

display("AAP");
lcdcmd(0xc0);
display("******************");
_delay_ms(1000);
PORTB=0b00000000;
}
else
{

display("SP");
lcdcmd(0xc0);
display("******************");
_delay_ms(1000);
PORTB=0b00000000;
   }



}}}



//THE HEADER FILE IS:--

void lcdcmd(char x)
{
PORTD=x;
PORTC=0b00000100;
_delay_ms(10);
PORTC=0b00000000;
_delay_ms(10);
}
void lcddata(char x)
{
PORTD=x;
        PORTC=0b00000101;
_delay_ms(10);
PORTC=0b00000001;
_delay_ms(10);
}
void display(char a[])
{
       int i;
for(i=0;a[i]!='\0';i++)
{lcddata(a[i]);
}
}
void lcd_init()
{
lcdcmd(0x38);
lcdcmd(0x0E);
lcdcmd(0x01);
}

Comments

Popular posts from this blog

AVR MICROCONTROLLER