- Aim: To take attendance using passive RFID tags.
- Code:
#define F_CPU 8000000UL
#define BAUD RATE 9600
#include<avr/io.h>
#include<util/delay.h>
#include<avr/io.h>
#include<util/delay.h>
void initialize();
void lcd_cmd(char value);
void lcd_data(char value);
void lcd_string(char *str);
void lcd_num(unsigned int number);
void usart_init();
void usart_transmit(char x);
char usart_recieve();
void initialize()
{
lcd_cmd(0x01); //clear LCD
lcd_cmd(0x02); //home position
lcd_cmd(0x06); //L-R
//lcd_cmd(0x04);
lcd_cmd(0x28); //4 bit mode
lcd_cmd(0x0C); //character generation
}
void lcd_cmd(char value)
{
int un,ln; // pc7-pc4 = un ; pc3-pc4 =ln
un=value&0xF0; // & is anding function
PORTC=0x04|un;
_delay_ms(2);
PORTC=0x00|un;
_delay_ms(2);
ln=(value<<4)&0xF0; //<<=left shif by 4 bits
_delay_ms(2);
PORTC=0x04|ln;
_delay_ms(2);
PORTC=0x00|ln;
}
void lcd_data(char value)
{
int un,ln; // pc7-pc4 = un ; pc3-pc4 =ln
un=value&0xF0; // & is anding function
PORTC=0x05|un;
_delay_ms(2);
PORTC=0x01|un;
_delay_ms(2);
ln=(value<<4)&0xF0; //<<=left shif by 4 bits
_delay_ms(2);
PORTC=0x05|ln;
_delay_ms(2);
PORTC=0x01|ln;
}
void lcd_string(char *str)
{
int i=0;
while(str[i]!='\0')
{
lcd_data(str[i]);
i++;
}
}
void lcd_num(unsigned int number)
{
lcd_cmd(0x04);
int d=0;
if(number>0){
while(number!=0)
{
d=number%10;
lcd_data(d+48);
number=number/10;
}}
else lcd_string("0");
}
void usart_init();
void usart_transmit(char x);
char usart_recieve();
void usart_init(){
UBRRH=0;
UBRRL=51; // or 0x33
UCSRB=0x18;
UCSRC=0x86;
}
void usart_transmit(char x){
while((UCSRA&0x20)==0);
UDR=x; //data gets stored in UDR
}
char usart_recieve(){
while((UCSRA&0x80)==0);//Till it gets overflow
return UDR;
}
char a[11];
void check(){
int i=0;
lcd_cmd(0x01);
for(i=0;i<12;i++){
a[i]=usart_recieve();
}
i=0;
}
int main()
{
DDRC=0xFF;
initialize();
_delay_ms(2);
usart_init();
_delay_ms(2);
check();
int i=0;
while(i<12){
if(a[0]=='1' && a[1]=='8' && a[2]=='0' && a[3]=='0' && a[4]=='3' && a[5]=='D' && a[6]=='A' && a[7]=='C' && a[8]=='D' && a[9]=='4' && a[10]=='5' && a[11]=='D')
{
lcd_cmd(0x01);
lcd_cmd(0x80);
lcd_string("Vishal Present");
_delay_ms(1000);
i=0;
check();
i=0;
}
else if(a[0]=='0' && a[1]=='D' && a[2]=='0' && a[3]=='0' && a[4]=='7' && a[5]=='7' && a[6]=='0' && a[7]=='9' && a[8]=='9' && a[9]=='B' && a[10]=='E' && a[11]=='8')
{
lcd_cmd(0x01);
lcd_cmd(0x80);
lcd_string("Vishnu Present");
_delay_ms(1000);
i=0;
check();
i=0;
}
else{
i=0;
check();
lcd_cmd(0xC0);
lcd_string("NOT VALID");
_delay_ms(100);
i=0;
}
i++;
}
}
#define BAUD RATE 9600
#include<avr/io.h>
#include<util/delay.h>
#include<avr/io.h>
#include<util/delay.h>
void initialize();
void lcd_cmd(char value);
void lcd_data(char value);
void lcd_string(char *str);
void lcd_num(unsigned int number);
void usart_init();
void usart_transmit(char x);
char usart_recieve();
void initialize()
{
lcd_cmd(0x01); //clear LCD
lcd_cmd(0x02); //home position
lcd_cmd(0x06); //L-R
//lcd_cmd(0x04);
lcd_cmd(0x28); //4 bit mode
lcd_cmd(0x0C); //character generation
}
void lcd_cmd(char value)
{
int un,ln; // pc7-pc4 = un ; pc3-pc4 =ln
un=value&0xF0; // & is anding function
PORTC=0x04|un;
_delay_ms(2);
PORTC=0x00|un;
_delay_ms(2);
ln=(value<<4)&0xF0; //<<=left shif by 4 bits
_delay_ms(2);
PORTC=0x04|ln;
_delay_ms(2);
PORTC=0x00|ln;
}
void lcd_data(char value)
{
int un,ln; // pc7-pc4 = un ; pc3-pc4 =ln
un=value&0xF0; // & is anding function
PORTC=0x05|un;
_delay_ms(2);
PORTC=0x01|un;
_delay_ms(2);
ln=(value<<4)&0xF0; //<<=left shif by 4 bits
_delay_ms(2);
PORTC=0x05|ln;
_delay_ms(2);
PORTC=0x01|ln;
}
void lcd_string(char *str)
{
int i=0;
while(str[i]!='\0')
{
lcd_data(str[i]);
i++;
}
}
void lcd_num(unsigned int number)
{
lcd_cmd(0x04);
int d=0;
if(number>0){
while(number!=0)
{
d=number%10;
lcd_data(d+48);
number=number/10;
}}
else lcd_string("0");
}
void usart_init();
void usart_transmit(char x);
char usart_recieve();
void usart_init(){
UBRRH=0;
UBRRL=51; // or 0x33
UCSRB=0x18;
UCSRC=0x86;
}
void usart_transmit(char x){
while((UCSRA&0x20)==0);
UDR=x; //data gets stored in UDR
}
char usart_recieve(){
while((UCSRA&0x80)==0);//Till it gets overflow
return UDR;
}
char a[11];
void check(){
int i=0;
lcd_cmd(0x01);
for(i=0;i<12;i++){
a[i]=usart_recieve();
}
i=0;
}
int main()
{
DDRC=0xFF;
initialize();
_delay_ms(2);
usart_init();
_delay_ms(2);
check();
int i=0;
while(i<12){
if(a[0]=='1' && a[1]=='8' && a[2]=='0' && a[3]=='0' && a[4]=='3' && a[5]=='D' && a[6]=='A' && a[7]=='C' && a[8]=='D' && a[9]=='4' && a[10]=='5' && a[11]=='D')
{
lcd_cmd(0x01);
lcd_cmd(0x80);
lcd_string("Vishal Present");
_delay_ms(1000);
i=0;
check();
i=0;
}
else if(a[0]=='0' && a[1]=='D' && a[2]=='0' && a[3]=='0' && a[4]=='7' && a[5]=='7' && a[6]=='0' && a[7]=='9' && a[8]=='9' && a[9]=='B' && a[10]=='E' && a[11]=='8')
{
lcd_cmd(0x01);
lcd_cmd(0x80);
lcd_string("Vishnu Present");
_delay_ms(1000);
i=0;
check();
i=0;
}
else{
i=0;
check();
lcd_cmd(0xC0);
lcd_string("NOT VALID");
_delay_ms(100);
i=0;
}
i++;
}
}
- Hardware information:
- EM18 Module
- Additional Information
1)Passive RFID tags have a distance limit of nearly 10 cm.
2)Active RFID tags have much larger range but they need an external power supply.
3) Its applications are :
a) can be used in supermarkets for shopping which will eliminate counters and time wasted there.
b) Can be used in toll gates for instant payment and save us some time.
c) Can be used in security systems.
Note: However, one major issue is that RFID tags are easy to hack and may be that's why these are not used in security systems. So maybe in future with more advanced RFID tags this would be possible.
3) Its applications are :
a) can be used in supermarkets for shopping which will eliminate counters and time wasted there.
b) Can be used in toll gates for instant payment and save us some time.
c) Can be used in security systems.
Note: However, one major issue is that RFID tags are easy to hack and may be that's why these are not used in security systems. So maybe in future with more advanced RFID tags this would be possible.
- Conclusion:
Comments
Post a Comment