Mario Tkalac
/
RFID-LCD-test_copy
Linija pogona
Fork of RFID-RC522 by
Diff: main.cpp
- Revision:
- 4:e0bc23d5134a
- Parent:
- 3:30e31f03d156
diff -r 30e31f03d156 -r e0bc23d5134a main.cpp --- a/main.cpp Sun May 08 13:27:52 2016 +0000 +++ b/main.cpp Wed Nov 22 08:55:19 2017 +0000 @@ -15,6 +15,7 @@ #include "mbed.h" #include "MFRC522.h" +#include "TextLCD.h" // Nucleo Pin for MFRC522 reset (pick another D pin if you need D8) #define MF_RESET p15 @@ -25,18 +26,26 @@ DigitalOut LedGreen(LED1); +//LCD text display status +TextLCD lcd(p10, p11, p27, p28, p29, p30); // rs, e, d4-d7 + //Serial connection to PC for output Serial pc(USBTX, USBRX); MFRC522 RfChip (SPI_MOSI, SPI_MISO, SPI_SCK, SPI_CS, MF_RESET); +unsigned char tagRX[20]; //array to store incoming tag +int tagRXindex=0; //keeps track of the index in tagRX +bool tagIncomingFlag=false; //flag to indicate that a new tag is busy being read +bool newtagFlag=false; //flag to indicate that a new tag was finished being read + int main(void) { - pc.printf("starting...\r\n"); + lcd.printf("starting...\r\n"); // Init. RC522 Chip RfChip.PCD_Init(); - pc.printf("init passed\r\n"); + lcd.printf("init passed\r\n"); while (true) { @@ -53,23 +62,37 @@ if (!RfChip.PICC_ReadCardSerial()) { wait_ms(500); - pc.printf("card read\r\n"); + lcd.printf("card read\r\n"); continue; } LedGreen = 0; - // Print Card UID - pc.printf("Card UID: "); + // Print Card UID - original + //lcd.printf("Card UID: "); + //for (uint8_t i = 0; i < RfChip.uid.size; i++) + //{ + // lcd.printf(" %X02", RfChip.uid.uidByte[i]); + //} + //lcd.printf("\n\r"); + + // Print Card UID - mario + //lcd.cls(); + //lcd.printf("Card UID: "); for (uint8_t i = 0; i < RfChip.uid.size; i++) { - pc.printf(" %X02", RfChip.uid.uidByte[i]); + tagRX[i] = RfChip.uid.uidByte[i]; } - pc.printf("\n\r"); + lcd.printf("\n\r"); // Print Card type - uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak); - pc.printf("PICC Type: %s \n\r", RfChip.PICC_GetTypeName(piccType)); + //uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak); + //lcd.printf("PICC Type: %s \n\r", RfChip.PICC_GetTypeName(piccType)); + + lcd.cls(); + lcd.printf("Card UID: "); + lcd.printf(" %s", tagRX); + wait_ms(1000); } } \ No newline at end of file