LCD display, Teraterm display
Dependencies: ID12RFID ID12RFID_HelloWorld TextLCD mbed
Fork of ID12RFID_HelloWorld by
main.cpp@3:61e6bd867047, 2015-07-15 (annotated)
- Committer:
- nmoorthy2001
- Date:
- Wed Jul 15 09:21:34 2015 +0000
- Revision:
- 3:61e6bd867047
- Parent:
- 2:53965de58fda
RFID reader with 16x2 LCD, TeraTerm
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon | 0:df71eb8a3c0b | 1 | #include "mbed.h" |
nmoorthy2001 | 2:53965de58fda | 2 | #include "TextLCD.h" |
nmoorthy2001 | 3:61e6bd867047 | 3 | |
nmoorthy2001 | 2:53965de58fda | 4 | Serial rx(NC, PTA1); // uart rx |
nmoorthy2001 | 2:53965de58fda | 5 | Serial pc(USBTX, USBRX); |
nmoorthy2001 | 2:53965de58fda | 6 | TextLCD lcd(PTA13, PTD5, PTD0, PTD1, PTD2, PTD3, TextLCD::LCD16x2); // RS, E, D4-D7 |
nmoorthy2001 | 3:61e6bd867047 | 7 | |
nmoorthy2001 | 3:61e6bd867047 | 8 | |
nmoorthy2001 | 2:53965de58fda | 9 | int count = 0; |
nmoorthy2001 | 2:53965de58fda | 10 | int input[12]; |
nmoorthy2001 | 2:53965de58fda | 11 | bool flag = 0; |
nmoorthy2001 | 3:61e6bd867047 | 12 | char a[12]= "1518"; |
nmoorthy2001 | 3:61e6bd867047 | 13 | char b[12]= "151F"; |
nmoorthy2001 | 3:61e6bd867047 | 14 | |
nmoorthy2001 | 3:61e6bd867047 | 15 | char d[12]="\0"; |
nmoorthy2001 | 3:61e6bd867047 | 16 | int i=0; |
nmoorthy2001 | 3:61e6bd867047 | 17 | int k; |
nmoorthy2001 | 3:61e6bd867047 | 18 | int numa=0; |
nmoorthy2001 | 3:61e6bd867047 | 19 | int numb=0; |
nmoorthy2001 | 3:61e6bd867047 | 20 | int numc=0; |
nmoorthy2001 | 2:53965de58fda | 21 | |
nmoorthy2001 | 2:53965de58fda | 22 | int main() |
nmoorthy2001 | 2:53965de58fda | 23 | { |
nmoorthy2001 | 2:53965de58fda | 24 | pc.printf("Welcome to RFID Access\n"); |
nmoorthy2001 | 2:53965de58fda | 25 | lcd.locate(0,0); |
nmoorthy2001 | 2:53965de58fda | 26 | lcd.printf("RF ID:"); |
nmoorthy2001 | 2:53965de58fda | 27 | |
nmoorthy2001 | 2:53965de58fda | 28 | rx.baud(9600); |
nmoorthy2001 | 3:61e6bd867047 | 29 | |
nmoorthy2001 | 2:53965de58fda | 30 | while(1) |
nmoorthy2001 | 2:53965de58fda | 31 | { |
nmoorthy2001 | 2:53965de58fda | 32 | /* if (rx.readable()) |
nmoorthy2001 | 2:53965de58fda | 33 | { |
nmoorthy2001 | 2:53965de58fda | 34 | pc.printf("%02x\n", rx.getc()); |
nmoorthy2001 | 2:53965de58fda | 35 | } |
nmoorthy2001 | 2:53965de58fda | 36 | */ |
nmoorthy2001 | 3:61e6bd867047 | 37 | |
nmoorthy2001 | 2:53965de58fda | 38 | if(rx.readable()) |
nmoorthy2001 | 2:53965de58fda | 39 | { |
nmoorthy2001 | 2:53965de58fda | 40 | count = 0; |
nmoorthy2001 | 2:53965de58fda | 41 | while(rx.readable() && count < 12) |
nmoorthy2001 | 2:53965de58fda | 42 | { |
nmoorthy2001 | 2:53965de58fda | 43 | input[count] = rx.getc(); |
nmoorthy2001 | 2:53965de58fda | 44 | pc.printf("%d %c\n", count, input[count]); |
nmoorthy2001 | 3:61e6bd867047 | 45 | if(input[count]==a[i]) |
nmoorthy2001 | 3:61e6bd867047 | 46 | { |
nmoorthy2001 | 3:61e6bd867047 | 47 | d[i]=a[i]; |
nmoorthy2001 | 3:61e6bd867047 | 48 | goto inc; |
nmoorthy2001 | 3:61e6bd867047 | 49 | } |
nmoorthy2001 | 3:61e6bd867047 | 50 | else if(input[count]==b[i]) |
nmoorthy2001 | 3:61e6bd867047 | 51 | { |
nmoorthy2001 | 3:61e6bd867047 | 52 | d[i]=a[i]; |
nmoorthy2001 | 3:61e6bd867047 | 53 | goto inc; |
nmoorthy2001 | 3:61e6bd867047 | 54 | } |
nmoorthy2001 | 3:61e6bd867047 | 55 | |
nmoorthy2001 | 3:61e6bd867047 | 56 | else |
nmoorthy2001 | 3:61e6bd867047 | 57 | { |
nmoorthy2001 | 3:61e6bd867047 | 58 | pc.printf("not valid/n"); |
nmoorthy2001 | 3:61e6bd867047 | 59 | exit(0); |
nmoorthy2001 | 3:61e6bd867047 | 60 | } |
nmoorthy2001 | 2:53965de58fda | 61 | lcd.locate(count,1); |
nmoorthy2001 | 2:53965de58fda | 62 | lcd.putc(input[count]); |
nmoorthy2001 | 3:61e6bd867047 | 63 | |
nmoorthy2001 | 3:61e6bd867047 | 64 | |
nmoorthy2001 | 3:61e6bd867047 | 65 | inc: count++; |
nmoorthy2001 | 3:61e6bd867047 | 66 | if(count==12) |
nmoorthy2001 | 3:61e6bd867047 | 67 | { |
nmoorthy2001 | 3:61e6bd867047 | 68 | k=strcmp(a,d); |
nmoorthy2001 | 3:61e6bd867047 | 69 | if(k==0) |
nmoorthy2001 | 3:61e6bd867047 | 70 | { |
nmoorthy2001 | 3:61e6bd867047 | 71 | numa=numa+1; |
nmoorthy2001 | 3:61e6bd867047 | 72 | pc.printf("Attendance taken\n"); |
nmoorthy2001 | 3:61e6bd867047 | 73 | pc.printf("%d",numa); |
nmoorthy2001 | 3:61e6bd867047 | 74 | } |
nmoorthy2001 | 3:61e6bd867047 | 75 | k=strcmp(b,d); |
nmoorthy2001 | 3:61e6bd867047 | 76 | if(k==0) |
nmoorthy2001 | 3:61e6bd867047 | 77 | { |
nmoorthy2001 | 3:61e6bd867047 | 78 | numb=numb+1; |
nmoorthy2001 | 3:61e6bd867047 | 79 | lcd.printf("Attendance taken\n"); |
nmoorthy2001 | 3:61e6bd867047 | 80 | pc.printf("%d",numb); |
nmoorthy2001 | 3:61e6bd867047 | 81 | } |
nmoorthy2001 | 3:61e6bd867047 | 82 | } |
nmoorthy2001 | 2:53965de58fda | 83 | } |
simon | 0:df71eb8a3c0b | 84 | } |
simon | 0:df71eb8a3c0b | 85 | } |
nmoorthy2001 | 3:61e6bd867047 | 86 | |
nmoorthy2001 | 3:61e6bd867047 | 87 | } |