Marvas / Mbed 2 deprecated rfid_kart_okuma

Dependencies:   mbed MFRC522 TextLCD

main.cpp

Committer:
marvas
Date:
2019-12-11
Revision:
0:cc98cfec2221

File content as of revision 0:cc98cfec2221:

//rfid ve lcd ekran kullanimi

#include "mbed.h"
#include "TextLCD.h"
#include <iostream>
 #include "MFRC522.h"
Serial seriport(USBTX,USBRX);
TextLCD lcd(PB_0,PA_4,PC_3,PC_2,PB_3,PA_10);


 //KL25Z Pins for MFRC522 SPI interface
 #define SPI_MOSI    PA_7 //Master output slave input
 #define SPI_MISO    PA_6  //Master input slave Output
 #define SPI_SCLK    PA_5 //SCK Clock pulse saat darbesi
 #define SPI_CS      PB_6 //SDA data pini
 // KL25Z Pin for MFRC522 reset
 #define MF_RESET    PC_7 //RST

 MFRC522  RfChip(SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_CS, MF_RESET);

 int main(void) {

   // Init. RC522 Chip
   RfChip.PCD_Init();

   while (true) {


     // Look for new cards
     if ( ! RfChip.PICC_IsNewCardPresent())
     {
       wait_ms(100);
       continue;
     }



     // Select one of the cards
     if ( ! RfChip.PICC_ReadCardSerial())
     {
       wait_ms(100);
       continue;
     }

     // Print Card UID
     printf("Kart ID: ");
     for (uint8_t i = 0; i < RfChip.uid.size; i++)
     {
       printf(" %X", RfChip.uid.uidByte[i]);
     }
     printf("\n");

     // Print Card type
     uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak);
     printf("PICC Type: %s \n\r", RfChip.PICC_GetTypeName(piccType));
   }
 }