Saturday, 17 September 2016

RFID Attendence System

RFID Attendence System:


Code:


#include<lpc214x.h>
#include<string.h>
#define PLLE 0
#define PLLC 1
#define PLOCK 10
#define DLAB 7
#define TEMT 6
#define DR 0
#define rs 16
#define rw 17
#define en 18
#define lcdport IO0SET
#define lcdportclr IO0CLR
void pll_init(void);
void delay(int);
void uart0_init(void);
void lcd_init(void );
void daten(void);
void cmnd(void);
void delay(int);
void lcdcmd(char);
void lcddata(char);
void lcdstring(char *);
char emp1[]="1600669C55B0";
char emp2[]="160066C78555";
char emp3[]="160055083149";
char emp4[]="110000342F04";
char id[12];
int i;
int main()
{
pll_init();
uart0_init();
lcd_init();
xyz: lcdcmd(0x01);lcdcmd(0x80);
  lcdstring("PLACE CARD");delay(100);
  while(1)
{
for(i=0;i<=11;i++)
{
   while( (U0LSR & (1<<DR)) ==0);
      id[i]=U0RBR;
    }
      id[i]='\0';

if((strcmp(id,emp1)==0))
{
lcdcmd(0x01);lcdcmd(0xc0);
lcdstring("U R EMP1");delay(500);
}
else if((strcmp(id,emp2)==0))
{
lcdcmd(0x01);lcdcmd(0xc0);
lcdstring("U R EMP2");delay(500);
}
else if((strcmp(id,emp3)==0))
{
lcdcmd(0x01);lcdcmd(0xc0);
lcdstring("U R EMP3");delay(500);
}
else if((strcmp(id,emp4)==0))
{
lcdcmd(0x01);lcdcmd(0xc0);
lcdstring("U R EMP4");delay(500);
}
else{
  lcdcmd(0x01);lcdcmd(0xc0);
lcdstring("WORONG ENTRY");delay(500);
}
  goto xyz;
  }
return 0;
}
void uart0_init()
{
PINSEL0|=5;
U0LCR=0x83;
U0DLL=97;
U0DLM=0x00;
U0LCR=U0LCR&~(1<<DLAB);
}
void pll_init()
{
 PLL0CFG=0x24;
 PLL0CON=PLL0CON|(1<<PLLE);
 PLL0FEED=0xAA;
 PLL0FEED=0x55;
 //PLL0CON=PLL0CON|(1<<PLLC);
 while( (PLL0STAT & (1<<PLOCK))==0);
 PLL0CON=PLL0CON|3;
 PLL0FEED=0xAA;
 PLL0FEED=0x55;
 VPBDIV=0x00;
}
void delay(int ms)
{
T1CTCR=0x00;
T1TC=0;
T1PC=0;
T1PR=59999;
T1TCR=0x02;
T1TCR=0x01;
while( T1TC != ms);
T1TCR=0;
}
void lcd_init()
{
IO0DIR=IO0DIR|(0x7f<<16);
lcdcmd(0x02);
lcdcmd(0x28);
lcdcmd(0x01);
lcdcmd(0x0e);
lcdcmd(0x80);
}
void lcdcmd(char ch)
{
lcdport = ((ch&0xf0)<<15);
cmnd();
lcdportclr = ((ch&0xf0)<<15);

lcdport = (((ch<<4)&0xf0)<<15);
cmnd();
lcdportclr = (((ch<<4)&0xf0)<<15);
}

void lcddata(char ch)
{
lcdport = ((ch&0xf0)<<15);
daten();
lcdportclr = ((ch&0xf0)<<15);

lcdport = (((ch<<4)&0xf0)<<15);
daten();
lcdportclr = (((ch<<4)&0xf0)<<15);
}
void cmnd()
{
lcdportclr = (1<<rs);
lcdportclr = (1<<rw);
lcdport = (1<<en);
delay(1);
lcdportclr = (1<<en);
delay(2);
}
void daten()
{
lcdport = (1<<rs);
lcdportclr = (1<<rw);
lcdport = (1<<en);
delay(1);
lcdportclr = (1<<en);
delay(2);
}

void lcdstring(char  *x)
{
while( *x != '\0')
{
lcddata(*x);
x++;
}
}

Simulation:




1 comment:

if you have any doubt please let me know