Sie sind auf Seite 1von 9

#include <string.

h>
#include <lcd.c>
#include <stdio.h>
#include <stdlib.h>
void time();
unsigned int date();
unsigned int hh=0,ss=00,mm=00,count=1,leap=0;
unsigned int Month=0,Days=0,hour=0;
unsigned long int Year=1999;
unsigned int i,j,k,value1=0,check,open,close,flag=0,len;
unsigned char b[11],c[11];
char a;
#int_TIMER1
void TIMER1_isr()
{
if(count==8)
{
count=0;
ss=ss+1;
if(ss == 60) {mm++; ss=0;
if(mm == 60) {hh++; mm=0;
if(hh == 24) {Days++; hh=0;
if ( (Days == 29 && Month==2 && leap==1)
|| (Days == 30 && Month==2)
|| (Days == 31 && (Month==4 || Month==6 || Month==9 ||
|| (Days == 32)
) {Month++;Days=1;}
if(Month == 13) {Year++; Month=1;}
}
}
}
}
count++;
set_timer1(0);
}
struct teacherdata
{
unsigned char teacherid[11];
unsigned char teachername[5];
}teacher[4];
struct studentdata
{
unsigned char studentid[11];
unsigned char studentname[5];
unsigned int attendance;
unsigned int enter;
}student[4];
void main()
{
strcpy(teacher[0].teacherid,"080069D695");
strcpy(teacher[0].teachername,"VINU");
strcpy(teacher[1].teacherid,"08006A86E2");
strcpy(teacher[1].teachername,"ARUN");
strcpy(student[0].studentid,"08006A545A");
strcpy(student[0].studentname,"RAJU");
student[0].attendance=00;
strcpy(student[1].studentid,"08006A4DD7");
strcpy(student[1].studentname,"ANJU");
student[1].attendance=00;

Month==11 ))

strcpy(student[2].studentid,"08006A9511");
strcpy(student[2].studentname,"MINI");
student[2].attendance=00;
strcpy(student[3].studentid,"080067C391");
strcpy(student[3].studentname,"AMAR");
student[3].attendance=00;
lcd_init();
lcd_gotoxy(1,1);
printf(lcd_putc,"SET TIME (24HR)");
delay_ms(1000);
time();
date();
Year=Year-2000;
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
enable_interrupts(INT_TIMER1);
enable_interrupts(GLOBAL);
set_timer1(0);
lcd_putc('\f');
goto begin1;
aas:
lcd_gotoxy(1,1);
printf(lcd_putc,"ATTENDANCE CLOSED");
delay_ms(10);
begin:
lcd_putc('\f');
begin1:
lcd_gotoxy(1,1);
printf(lcd_putc," ATTENDANCE S/M ");
lcd_gotoxy(1,2);
printf(lcd_putc,"%02u",hh);
lcd_gotoxy(3,2);
printf(lcd_putc,":%02u",mm);
lcd_gotoxy(9,2);
printf(lcd_putc,"%02u",Days);
lcd_gotoxy(11,2);
printf(lcd_putc,"/%02u",Month);
lcd_gotoxy(14,2);
printf(lcd_putc,"/%02lu",Year);
output_low(PIN_B0);
open=input(PIN_B0);
output_low(PIN_a0);
check=input(PIN_a0);
if(check==1)
{
for(i=0;i<4;i++)
{
lcd_putc('\f');
lcd_gotoxy(1,1);
printf(lcd_putc,"NAME:
");
lcd_gotoxy(6,1);
printf(lcd_putc,student[i].studentname);
delay_ms(1500);
lcd_gotoxy(1,2);
printf(lcd_putc,"PRESENT HOURS: ");
lcd_gotoxy(15,2);
printf(lcd_putc,"%02u",student[i].attendance);
delay_ms(1500);
lcd_putc('\f');
if(check!=1)
{

goto begin;
}
}
}
if(open!=1)
{
goto begin1;
}
else
{
delay_ms(10);
lcd_gotoxy(1,2);
printf(lcd_putc,"SHOW TEACHER ID ");
gets(b);
i=0;
flag=0;
do
{
value1=strcmp(teacher[i].teacherid,b);
if(value1==0)
{
flag=1;
j=i;
}
i++;
}
while(i<=4);
if(flag==0)
{
lcd_putc('\f');
lcd_gotoxy(1,1);
printf(lcd_putc,"
WRONG ID
");
delay_ms(2000);
goto begin;
}
else
{
start:lcd_putc('\f');
lcd_gotoxy(1,1);
printf(lcd_putc,"WELCOME TEACHER ");
delay_ms(10);
lcd_gotoxy(1,2);
printf(lcd_putc,"
");
lcd_gotoxy(6,2);
printf(lcd_putc,teacher[j].teachername);
delay_ms(2000);
lcd_gotoxy(10,2);
printf(lcd_putc,"
");
delay_ms(10);
lcd_putc('\f');
if(hour==hh)
{
goto stud;
}
for(i=0;i<4;i++)
{
student[i].enter=00;
}
stud:hour=hh;
lcd_gotoxy(1,1);

printf(lcd_putc,"ATTENDANCE OPEN ");


lcd_gotoxy(1,2);
printf(lcd_putc,"
");
i=0;
k=0;
output_low(PIN_B0);
open=input(PIN_B0);
while(open)
{
close=input(PIN_a1);
if(close==0)
{
goto stud;
}
flag=0;
lcd_gotoxy(1,2);
printf(lcd_putc,"SHOW STUDENT ID");
open=input(PIN_B0);
if(open!=1)
{
goto aas;
}
gets(c);
i=0;
do
{
value1=strcmp(student[i].studentid,c);
if(value1==0)
{
k=i;
flag=1;
}
i++;
}
while(i<=4);
if(flag==0)
{
lcd_gotoxy(1,2);
printf(lcd_putc,"
WRONG ID
");
delay_ms(1000);
lcd_putc('\f');
open=input(PIN_B0);
close=input(PIN_B1);
goto stud;
}
else if(student[k].enter==0)
{
lcd_putc('\f');
lcd_gotoxy(1,1);
printf(lcd_putc,"NAME:
");
lcd_gotoxy(6,1);
printf(lcd_putc,student[k].studentname);
delay_ms(1000);
student[k].attendance++;
lcd_gotoxy(1,2);
printf(lcd_putc,"PRESENT HOURS: ");
lcd_gotoxy(15,2);
printf(lcd_putc,"%02u",student[k].attendance);
delay_ms(1000);
student[k].enter++;

lcd_putc('\f');
open=input(PIN_B0);
close=input(PIN_B1);
}
else if(student[k].enter!=0)
{
lcd_gotoxy(1,1);
printf(lcd_putc,"NAME:
");
lcd_gotoxy(6,1);
printf(lcd_putc,student[k].studentname);
delay_ms(1000);
lcd_gotoxy(1,2);
printf(lcd_putc,"ATTENDANCE TAKEN");
delay_ms(1000);
lcd_putc('\f');
}
}
goto aas;
}
}
}
void time()
{
lcd_gotoxy(1,2);
printf(lcd_putc,"HOUR :");
delay_ms(1000);
while(1)
{
if(input(pin_a0))
{
hh++;
lcd_gotoxy(7,2);
if((hh==24))
{
hh=0;
}
printf(lcd_putc,"%02u",hh);
delay_ms(250);
output_bit(pin_a0,0);
}
if(input(pin_a1))
{
delay_ms(1000);
goto L1;
}
}
L1:
lcd_gotoxy(1,2);
printf(lcd_putc,"MINUTE :");
delay_ms(1000);
output_bit(pin_a1,0);
while(1)
{
if(input(pin_a0))
{
mm++;
lcd_gotoxy(9,2);
if(mm==60)
{

mm=00;
}
printf(lcd_putc,"%02u",mm);
delay_ms(250);
output_bit(pin_a0,0);
}
if(input(pin_a1))
{
delay_ms(1000);
goto L2;
}
}
L2:
output_bit(pin_a1,0);
lcd_putc('\f');
lcd_gotoxy(1,1);
printf(lcd_putc,"
TIME SET ");
delay_ms(1000);
}
unsigned int date()
{
lcd_gotoxy(1,2);
printf(lcd_putc,"Year :");
output_bit(pin_a1,0);
delay_ms(1000);
while(1)
{
if(input(pin_a0))
{
Year++;
lcd_gotoxy(7,2);
if((Year==2100))
{
Year=2000;
}
printf(lcd_putc,"%lu",Year);
delay_ms(250);
output_bit(pin_a0,0);
}
if(input(pin_a1)==1)
{
delay_ms(1000);
goto L3;
}
}
L3:
if(Year%4==0)
{
leap=1;
}
lcd_gotoxy(1,2);
printf(lcd_putc,"
lcd_gotoxy(1,2);
printf(lcd_putc,"MONTH :");
delay_ms(1000);
output_bit(pin_a1,0);
while(1)
{

");

if(input(pin_a0))
{
Month++;
lcd_gotoxy(9,2);
if((Month==13))
{
Month=1;
}
printf(lcd_putc,"%02u",Month);
delay_ms(250);
output_bit(pin_a0,0);
}
if(input(pin_a1))
{
delay_ms(1000);
goto L4;
}
}
L4:
lcd_gotoxy(1,2);
printf(lcd_putc,"
");
lcd_gotoxy(1,2);
printf(lcd_putc,"DAY :");
delay_ms(1000);
output_bit(pin_a1,0);
if(Month==2 && leap==1)
{
while(1)
{
if(input(pin_a0))
{
Days++;
lcd_gotoxy(6,2);
if(Days==30)
{
Days=1;
}
printf(lcd_putc,"%02u",Days);
delay_ms(250);
output_bit(pin_a0,0);
}
if(input(pin_a1))
{
delay_ms(1000);
return 0;
}
}
}
else if(Month==2)
{
while(1)
{
if(input(pin_a0))
{
Days++;
lcd_gotoxy(6,2);
if(Days==29)

{
Days=1;
}
printf(lcd_putc,"%02u",Days);
delay_ms(250);
output_bit(pin_a0,0);
}
if(input(pin_a1))
{
delay_ms(1000);
return 0;
}
}
}
else if(Month==4 || Month==6 || Month==9 ||
{
while(1)
{
if(input(pin_a0))
{
Days++;
lcd_gotoxy(6,2);
if(Days==31)
{
Days=1;
}
printf(lcd_putc,"%02u",Days);
delay_ms(250);
output_bit(pin_a0,0);
}
if(input(pin_a1))
{
delay_ms(1000);
return 0;
}
}
}
else
{
while(1)
{
if(input(pin_a0))
{
Days++;
lcd_gotoxy(6,2);
if(Days==32)
{
Days=1;
}
printf(lcd_putc,"%02u",Days);
delay_ms(250);
output_bit(pin_a0,0);
}
if(input(pin_a1))
{
delay_ms(1000);
return 0;
}

Month==11 )

Das könnte Ihnen auch gefallen