Nucleo RFID EM18 125KHz low frequency
Revision 1:3781e9bf2c47, committed 2018-07-12
- Comitter:
- shivanandgowdakr
- Date:
- Thu Jul 12 09:57:11 2018 +0000
- Parent:
- 0:1a3020ba8001
- Commit message:
- DFROBOT UHF RFID; ; ;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Jul 12 06:57:41 2018 +0000
+++ b/main.cpp Thu Jul 12 09:57:11 2018 +0000
@@ -1,39 +1,73 @@
+
#include "mbed.h"
+Serial RfidUHF(PC_12,PD_2);
-// initialize the library with the numbers of the interface pins
-DigitalOut led(LED1);
-Serial EM18Rfid(PC_12,PD_2);
-
-int count = 0; //integer for storing character of ID
+unsigned char StopReadCode[5] = {0xa0,0x03,0xa8,0x00,0xb5};//Stop reading the label code
+unsigned char ResetCode[5]={0xa0,0x03,0x65,0x00,0xf8};//Reset code
+unsigned char StopReadCodeCB[6]={0xe0,0x04,0xa8,0x00,0x00,0x74};//Stop reading code success and return the value
+unsigned char ResetCodeCB[6]={0xe4,0x04,0x65,0x00,0x00,0xb3};//Reset code success and return the value
+unsigned char data[6]={};
-char input[12];//memory for storing 12 characters of ID
-
-int main()
-{
- EM18Rfid.baud(9600); //Baud Rate 9600
-
+ int main()
+ {
+ int i;
+ int n=1;
+
+
while(true)
-
- {
-
- while(EM18Rfid.readable() && count < 12) // Read 12 characters and store them in input array
-
- {
- input[count] = EM18Rfid.getc();
- count++;
- if (count==12)
- {
- led=1;
- input[count]='\0';
- printf("Read Tag Id is : %s\r\n",input);
- count = 0;// once 12 characters are read get to start and wait for 1 second before reading next ID
- wait(1);
- led=0;
+ {
+
+ wait(2.0);
+ while(n)
+ {
+ for(i=0; i<5;i++)
+ RfidUHF.putc(StopReadCode[i]);
+ wait(0.2);
+ if(RfidUHF.readable())
+ {
+ for(i=0;i<6;i++)
+ {
+ data[i]=RfidUHF.getc();
+ wait_ms(1);
+ }
+ for(i=0;i<6;i++)
+ {
+ if(data[i]==StopReadCodeCB[i])
+ n=0;
+ else
+ n=1;
+ }
}
- }
-
- }
-}
\ No newline at end of file
+ wait(0.5);
+ }
+
+ n=1;
+
+ while(n)
+ {
+ for(i=0; i<5;i++)
+ RfidUHF.putc(ResetCode[i]);
+
+ wait(0.2);
+ if(RfidUHF.readable())
+ {
+ for(i=0;i<6;i++)
+ {
+ data[i]=RfidUHF.getc();
+ wait(1);
+ }
+ for(i=0;i<6;i++)
+ {
+ if(data[i]==ResetCodeCB[i])
+ n=0;
+ else
+ n=1;
+ }
+ }
+ wait(0.5);
+ }
+ }
+ }
\ No newline at end of file