Code of Voting Machine Using Avr
Code of Voting Machine Using Avr
char a[]="0123456789";
void main()
{
int i=0;
int j=0;
int k=0;
lcd_init();
lcd_cmd(_lcd_cursor_off);
DDB0_bit=0;
DDB1_bit=0;
DDB2_bit=0;
DDB3_bit=0;
while(1)
{
lcd_out(1,3,"press key");
if(switch1==1)
{
i=i+1;
lcd_out(1,3,"thank you");
Delay_ms(500);
while(switch1==1);
Delay_ms(1000);
}
if(switch2==1)
{
j=j+1;
lcd_out(1,3,"thank you");
Delay_ms(500);
while(switch2==1);
Delay_ms(1000);
}
if(switch3==1)
{
k=k+1;
lcd_out(1,3,"thank you");
Delay_ms(500);
while(switch3==1);
Delay_ms(1000);
}
if(switch4==1)
{
if(i>j&&i>k)
{
while(1)
{
lcd_cmd(_lcd_clear);
lcd_out(1,2,"congrats AAP ");
Delay_ms(1000);
lcd_out(2,1,"votes to AAP=");
lcd_chr(2,14,a[(i/100)%10]);
lcd_chr(2,15,a[(i/10)%10]);
lcd_chr(2,16,a[i%10]);
Delay_ms(1000);
lcd_out(1,1,"votes to kkk=");
lcd_chr(1,14,a[(j/100)%10]);
lcd_chr(1,15,a[(j/10)%10]);
lcd_chr(1,16,a[j%10]);
Delay_ms(1000);
lcd_out(2,1,"votes to bjp=");
lcd_chr(2,14,a[(k/100)%10]);
lcd_chr(2,15,a[(k/10)%10]);
lcd_chr(2,16,a[k%10]);
Delay_ms(1000);
}
}
if(j>i&&j>k)
{
while(1)
{
lcd_cmd(_lcd_clear);
lcd_out(1,2,"congrats kkk");
Delay_ms(1000);
lcd_out(2,1,"votes to kkk=");
lcd_chr(2,14,a[(j/100)%10]);
lcd_chr(2,15,a[(j/10)%10]);
lcd_chr(2,16,a[j%10]);
Delay_ms(1000);
lcd_out(1,1,"votes to AAP=");
lcd_chr(1,14,a[(i/100)%10]);
lcd_chr(1,15,a[(i/10)%10]);
lcd_chr(1,16,a[i%10]);
Delay_ms(1000);
lcd_out(2,1,"votes to bjp=");
lcd_chr(2,14,a[(k/100)%10]);
lcd_chr(2,15,a[(k/10)%10]);
lcd_chr(2,16,a[k%10]);
Delay_ms(1000);
}
}
if(k>i&&k>j)
{
while(1)
{
lcd_cmd(_lcd_clear);
lcd_out(1,2,"congrats bjp");
Delay_ms(1000);
lcd_out(2,1,"votes to bjp=");
lcd_chr(2,14,a[(k/100)%10]);
lcd_chr(2,15,a[(k/10)%10]);
lcd_chr(2,16,a[k%10]);
Delay_ms(1000);
lcd_out(1,1,"votes to AAP=");
lcd_chr(1,14,a[(i/100)%10]);
lcd_chr(1,15,a[(i/10)%10]);
lcd_chr(1,16,a[i%10]);
Delay_ms(1000);
lcd_out(2,1,"votes to kkk=");
lcd_chr(2,14,a[(j/100)%10]);
lcd_chr(2,15,a[(j/10)%10]);
lcd_chr(2,16,a[j%10]);
Delay_ms(1000);
}
}
else
{
while(1)
{
lcd_out(2,1,"votes to bjp=");
lcd_chr(2,14,a[(k/100)%10]);
lcd_chr(2,15,a[(k/10)%10]);
lcd_chr(2,16,a[k%10]);
Delay_ms(1000);
lcd_out(1,1,"votes to AAP=");
lcd_chr(1,14,a[(i/100)%10]);
lcd_chr(1,15,a[(i/10)%10]);
lcd_chr(1,16,a[i%10]);
Delay_ms(1000);
lcd_out(2,1,"votes to kkk=");
lcd_chr(2,14,a[(j/100)%10]);
lcd_chr(2,15,a[(j/10)%10]);
lcd_chr(2,16,a[j%10]);
Delay_ms(1000);
}
}
}
}
}