It works.
I do not know C and i want to use it on Mikrobasc so i can develop more.
Here is the MikroC program
Code: Select all
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
void main()
{
char i,rfid[13] = "123456781212";
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1,1,"RFID Tag Reader"); // Write text in first row
UART1_Init(9600);
rfid[12] = '\0';
while(1)
{
if(UART1_Data_Ready())
{
for(i=0;i<12;)
{
if(UART1_Data_Ready())
{
rfid[i] = UART1_Read();
i++;
}
}
if((rfid[0] ^ rfid[2] ^ rfid[4] ^ rfid[6] ^ rfid[8] == rfid[10]) && (rfid[1] ^ rfid[3] ^ rfid[5] ^ rfid[7] ^ rfid[9] == rfid[11]))
{
Lcd_Out(2,1,rfid);
}
else
Lcd_Out(2,1,"Error ");
}
}
}
Code: Select all
dim LCD_RS as sbit at RB4_bit
dim LCD_EN as sbit at RB5_bit
dim LCD_D4 as sbit at RB0_bit
dim LCD_D5 as sbit at RB1_bit
dim LCD_D6 as sbit at RB2_bit
dim LCD_D7 as sbit at RB3_bit
dim LCD_RS_Direction as sbit at TRISB4_bit
dim LCD_EN_Direction as sbit at TRISB5_bit
dim LCD_D4_Direction as sbit at TRISB0_bit
dim LCD_D5_Direction as sbit at TRISB1_bit
dim LCD_D6_Direction as sbit at TRISB2_bit
dim LCD_D7_Direction as sbit at TRISB3_bit
main:
dim i as byte
dim rfid as string[13]
Lcd_Init() ' Initialize LCD
Lcd_Cmd(_LCD_CLEAR) 'Clear display
Lcd_Cmd(_LCD_CURSOR_OFF) ' Cursor off
Lcd_Out(1,1,"RFID Tag Reader") ' Write text in first row
UART1_Init(9600)
rfid[12]=0
while true
if(UART1_Data_Ready()) then
for i=0 to 11
if(UART1_Data_Ready()) then
rfid[i] = UART1_Read()
i = i + 1
end if
next i
end if
if ((rfid[0] xor rfid[2] xor rfid[4] xor rfid[6] = rfid[10]) and (rfid[1] xor rfid[3] xor rfid[5] xor rfid[7] xor rfid[9] = rfid[11])) then
Lcd_Out(2,1,rfid)
else
Lcd_Out(2,1,"Error ")
end if
wend
end.
Thank you very much in advance.