Sign In

RFID Module Is Not Sending The Unique ID Of Cards On LCD.It Is In Some Chinese Characters

pranjal rshbsaxena@gmail.com India

Hardware: Atmega 16 Dev Board With 12 MHz Frequency Software: Atmel Studio 6.1

I am making a security system project using AVR atmega 16 and RFID module. While testing the unique ID of the cards i am getting some chinese characters on LCD. I have done all the connnections neat & clean. I need help. Kindly help me out ASAP.

Images

Program

/*RFID BASE LIBRARY SECURITY SYSTEM
code written by Er Amit Singh(7042027562)
Name Of Project:LIBRARY BOOK arrangement BY RFID
*/
#define F_CPU 12000000UL
#include<avr/io.h>
#include<util/delay.h>
#include<string.h>
#define rs 0
#define rw 1
#define en 2
int i,t,g,j;
unsigned char arr[],arr2[],arr3[],arr8[];
void print(unsigned char data);
void lcd_print(unsigned char *a);
//static unsigned t=0;
void lcd_init();
void command();
void ddata();
void usart_init();
unsigned char get();
unsigned char cmd[]={0x02,0x28,0x0e,0x06,0x01,0x80};// 8 bit 0x38
unsigned char x;
/****************uart****************/
void uart_sendstr(unsigned char *str);
char get3();
void uart_data(unsigned char ch);

//void enterATMode(void);
/*********main-----------***********/
struct employees
{
	unsigned char name[20];
	unsigned char id_number[15];
	unsigned char number[16];
};
struct employees e1,e2,e3,e4;
struct employees e1={"Shubham","111111111111","+919536178570"};//amit singh
struct employees e2={"Piyush","222222222222","+918468943524"};
struct employees e3={"Amit","6FGG8RJGV8RF","+917827012019"};
struct employees e4={"Miftah","TY867UH786FT","+917508229422"};


void led1();
void led2();
void led3();
int main()
{
	DDRA=0Xff;
	DDRB=0XFF;
	lcd_init();
	usart_init();
	lcd_init();
	_delay_ms(100);
	led1();
	lcd_print("**WELCOME****");
	PORTB= ((0xc0)&(0xf0));
	command();
	_delay_ms(20);
	PORTB= ((0xc0<<4)&(0xf0));
	command();
	lcd_print("**RFID-LIBRARY******");
	PORTB= ((0x90)&(0xf0));
	command();
	_delay_ms(20);
	PORTB= ((0x90<<4)&(0xf0));
	command();
	lcd_print("*SECURITY-SYSTEM**");
	PORTB= ((0xd0)&(0xf0));
	command();
	_delay_ms(20);
	PORTB= ((0xd0<<4)&(0xf0));
	command();
	lcd_print("***********************");
	led2();
	lcd_init();
	lcd_print("show Book:");
	_delay_ms(2000);
	lcd_init();
	while(1)
	{

		for(i=0;i<12;i++)
		{
			arr8[i]=get3();
		}
		arr8[i]='';
		lcd_print(arr8);
		_delay_ms(000);
		
	}
	return 0;
}

void ddata()
{
	PORTB|=(1<<rs);
	PORTB&=~(1<<rw);
	PORTB|=(1<<en);
	_delay_ms(5);
	PORTB&=~(1<<en);
	return;
}
void command()
{
	PORTB&=~(1<<rs);
	PORTB&=~(1<<rw);
	PORTB|=(1<<en);
	_delay_ms(5);
	PORTB&=~(1<<en);
	return;
}
void print(unsigned char data)
{
	arr[t]=data;
	PORTB=(data)&(0xf0);
	ddata();
	_delay_ms(10);
	PORTB=(data<<4)&(0xf0);
	ddata();
	_delay_ms(10);
	t++;
}
lcd_print(unsigned char *str)
{
	unsigned char i=0;
	while(str[i]!='')
	{
		PORTB=(str[i])&(0xf0);
		ddata();
		_delay_ms(10);

		PORTB=(str[i]<<4)&(0xf0);
		ddata();
		_delay_ms(10);
		i++;

	}
}
lcd_init()
{
	for(int j=0;j<=7;j++)
	{
		PORTB= (*(cmd+j)&(0xf0));
		command();
		PORTB= (((cmd[j])<<4)&(0xf0));
		command();
		_delay_ms(20);
	}
}

unsigned char get()
{

	//UCSRA=(0<<U2X);
	while(!(UCSRA &(1<<RXC)));
	return(UDR);
}
void usart_init()
{
	UCSRB=(1<<RXEN)|(1<<TXEN);
	UCSRC=((1<<URSEL)|(1<<UCSZ0)|(1<<UCSZ1));
	UBRRL=0x4D ; // 12mhz  9600 baud rate
}

void uart_data(unsigned char ch)
{
	UDR=ch;
	_delay_ms(100);
	while(!(UCSRA &( 1<<UDRE)));
}
void uart_sendstr(unsigned char *str)
{
	
	while(1)
	{
		if(*str=='')
		break;
		uart_data(*str++);
	}
}
char get3()
{
	while(!(UCSRA &(1<<RXC)));
	return(UDR);
}

void led1()
{
	
	PORTA=0XFF;
}
void led2()
{
	PORTA=0xff;
	_delay_ms(1000);
	PORTA=0X00;
	_delay_ms(1000);
	PORTA=0Xff;
	_delay_ms(1000);
	PORTA=0X00;
	_delay_ms(1000);
	PORTA=0XFF;
}
void led3()
{
	for(int i=0;i<8;i++)
	{
		PORTA=(0x01<<i);
		_delay_ms(800);
	}
	
}







Replies

R Avinash Gupta
2016-09-12 04:27:06
Upload picture of your hardware setup and the schematic (circuit diagram) of the project.

Post a reply to pranjal

Think you can help pranjal ? Then post your thoughts that might help pranjal. You will earn a lot of reputation in the technical community.

If your program is in multiple files, then ZIP the entire folder and attach below

Images and Screenshots

These helps other better understand your suggestion.